diff --git a/Projects/NightRaider/Class1.cs b/Projects/NightRaider/Class1.cs index 90f1a20..270ad01 100644 --- a/Projects/NightRaider/Class1.cs +++ b/Projects/NightRaider/Class1.cs @@ -13,6 +13,7 @@ namespace CykaRaider { public static ConfigEntry lootTimeAdder; public static ConfigEntry maxStackMultiplier; + public static ConfigEntry autoLoot; public static ConfigEntry debugMode; @@ -20,6 +21,7 @@ namespace CykaRaider { debugMode = Config.Bind("General", "Debug Mode", false, new ConfigDescription("Debug Mode")); lootTimeAdder = Config.Bind("General", "Loot Time Adder", 0, new ConfigDescription("Loot Time Adder")); maxStackMultiplier = Config.Bind("General", "Max Stack Multiplier", 1f, new ConfigDescription("Max Stack Multiplier")); + autoLoot = Config.Bind("General", "Auto Loot", false, new ConfigDescription("Auto Loot")); Logger.LogInfo("Cyka mod loaded"); HarmonyFileLog.Enabled = true; diff --git a/Projects/NightRaider/CykaRaider.csproj b/Projects/NightRaider/CykaRaider.csproj index dc7aff3..f5b5ed0 100644 --- a/Projects/NightRaider/CykaRaider.csproj +++ b/Projects/NightRaider/CykaRaider.csproj @@ -52,6 +52,9 @@ $(GAME_MANAGED)/UnityEngine.CoreModule.dll + + $(GAME_MANAGED)/UnityEngine.UI.dll + $(GAME_MANAGED)/Assembly-CSharp.dll diff --git a/Projects/NightRaider/Patches.cs b/Projects/NightRaider/Patches.cs index a4379c1..4b93ca2 100644 --- a/Projects/NightRaider/Patches.cs +++ b/Projects/NightRaider/Patches.cs @@ -1,5 +1,6 @@ -using System; +using System; using HarmonyLib; +using UnityEngine.UI; namespace CykaRaider { @@ -23,18 +24,34 @@ namespace CykaRaider [HarmonyPostfix] [HarmonyPatch(typeof(DataHub), "GetFixedData")] - static void xpMultiplier(DataHub __instance) { - for (int i = 0; i < __instance.itemDataDic.Count; i++) { - var itemData = __instance.itemDataDic[i]; - if (itemData.maxStack > 0) { + static void maxStackMultiplier(DataHub __instance) { + foreach (var itemData in __instance.itemDataDic) { + if (itemData.Value.maxStack > 0) { if (Main.debugMode.Value) - Console.WriteLine("CykaRaider: GetFixedData: Old maxStack {0}", itemData.maxStack); - itemData.maxStack = (int)(itemData.maxStack * Main.maxStackMultiplier.Value); + Console.WriteLine("CykaRaider: GetFixedData: Old maxStack {0}", itemData.Value.maxStack); + itemData.Value.maxStack = (int)(itemData.Value.maxStack * Main.maxStackMultiplier.Value); if (Main.debugMode.Value) - Console.WriteLine("CykaRaider: GetFixedData: New maxStack {0}", itemData.maxStack); + Console.WriteLine("CykaRaider: GetFixedData: New maxStack {0}", itemData.Value.maxStack); } } } + + [HarmonyPostfix] + [HarmonyPatch(typeof(MyBagControl), "GetAllButtonShow")] + static void autoLoot(MyBagControl __instance) { + if (Main.autoLoot.Value) { + if (Main.debugMode.Value) + Console.WriteLine("CykaRaider: autoLoot: AutoLoot is enabled"); + var trav = Traverse.Create(__instance); + var button = trav.Field("getAll_BT").GetValue