diff --git a/Patches/QuickSell.cs b/Patches/QuickSell.cs index c329deb..885d6df 100644 --- a/Patches/QuickSell.cs +++ b/Patches/QuickSell.cs @@ -21,6 +21,7 @@ using static System.Collections.Specialized.BitVector32; using TMPro; using QuickSell.Patches; +using SPT.Reflection.Utils; namespace QuickSell.Patches { @@ -28,6 +29,8 @@ namespace QuickSell.Patches internal class ContextMenuPatch : ModulePatch // all patches must inherit ModulePatch { + private static TraderClass[] traders = null; + protected override MethodBase GetTargetMethod() { return typeof(SimpleContextMenu).GetMethod(nameof(SimpleContextMenu.method_0)).MakeGenericMethod(typeof(EItemInfoButton)); @@ -190,9 +193,14 @@ public static Action FleaCallbackFactory(Item item, ItemMarket // Returns Trader with best offer of null if unsellable private static TraderClass selectTrader(Item item) { + if (traders == null) + { + forceReloadTraders(); + } + TraderClass best = null; int bestOffer = 0; - foreach (var trader in Singleton.Instance.TraderScreensGroup.IEnumerable_0) + foreach (var trader in traders) { var price = trader.GetUserItemPrice(item); @@ -221,5 +229,14 @@ private static void PlaySellSound() Singleton.Instance.PlayUISound(EUISoundType.TradeOperationComplete); } + private static void forceReloadTraders() + { + var app = ClientAppUtils.GetMainApp(); + + var mainMenu = (MainMenuController) typeof(TarkovApplication).GetField("mainMenuController", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(app); + var iSession = (ISession)typeof(MainMenuController).GetField("iSession", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(mainMenu); + traders = iSession.Traders.Where(new Func(MainMenuController.Class1271.class1271_0.method_4)).ToArray(); + } + } } \ No newline at end of file diff --git a/Patches/TraderLoadingPatch.cs b/Patches/TraderLoadingPatch.cs index 6a37d41..b7690a6 100644 --- a/Patches/TraderLoadingPatch.cs +++ b/Patches/TraderLoadingPatch.cs @@ -27,7 +27,7 @@ private static bool Prefix(MainMenuController __instance, EMenuType screen, bool { if (screen == EMenuType.Player) { - __instance.method_34(); + //__instance.method_34(); __instance.method_35(); } diff --git a/Plugin.cs b/Plugin.cs index 7975755..6dc364d 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -11,13 +11,23 @@ namespace QuickSell { - [BepInPlugin("QuickSell.UniqueGUID", "QuickSell", "1.0.1")] + [BepInPlugin("QuickSell.UniqueGUID", "QuickSell", "1.0.2")] public class Plugin : BaseUnityPlugin { - + + public static bool EnableQuickSellFlea = true; + public static bool EnableQuickSellTraders = true; + public static bool ShowConfirmationDialog = true; + public static string[] TradersBlacklist = new string[] { }; + + public static double AvgPricePercent = 100; + + public static string TraderSellKey = "B"; + public static string FleaSellKey = "N"; + + public static bool IgnoreFleaCapacity = false; public static ManualLogSource LogSource; - public MainMenuController mmController; private void Awake() {