using System; using System.Collections.Generic; using System.Reflection.Emit; using HarmonyLib; using UnityEngine.UI; namespace CykaRaider { [HarmonyPatch] public class Patches { [HarmonyPostfix] [HarmonyPatch(typeof(GameManager), "FixedUpdate")] static void lootTimeAdder(GameManager __instance) { var trav = Traverse.Create(__instance); var lootTime = trav.Field("lootTime").GetValue(); if (lootTime > 0) { if (Main.debugMode.Value) Console.WriteLine("CykaRaider: FixedUpdate: Old lootTime {0}", lootTime); lootTime += Main.lootTimeAdder.Value; if (Main.debugMode.Value) Console.WriteLine("CykaRaider: FixedUpdate: New lootTime {0}", lootTime); trav.Field("lootTime").SetValue(lootTime); } } [HarmonyPostfix] [HarmonyPatch(typeof(DataHub), "GetFixedData")] 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.Value.maxStack); itemData.Value.maxStack = (int)(itemData.Value.maxStack * Main.maxStackMultiplier.Value); if (Main.debugMode.Value) 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