using System.Linq; using Il2CppFunGI.ATTT.Game.Gameplay.FinancialReport; using Il2CppSystem; using MelonLoader; using UnityEngine; namespace ArmsTradeTycoonTanks { public static class Global { private static MelonPreferences_Category category; public static MelonPreferences_Entry Debug; public static MelonPreferences_Entry MoneyMultiplier; public static void InitializePreferences() { category = MelonPreferences.CreateCategory("ArmsTradeTycoonTanksMelonMod"); Debug = category.CreateEntry("Debug", true, description: "Enable debug mode"); MoneyMultiplier = category.CreateEntry("MoneyMultiplier", 1.0f, description: "Multiplier for money gains"); } } public class ArmsTradeTycoonTanksMelonMod : MelonMod { public override void OnApplicationStart() { Global.InitializePreferences(); } public override void OnInitializeMelon() { LoggerInstance.Msg("Phat Melon mod loaded"); HarmonyLib.Harmony harmony = HarmonyInstance; harmony.PatchAll(); var originalMethods = harmony.GetPatchedMethods(); var methodBases = originalMethods.ToList(); LoggerInstance.Msg("Patched " + methodBases.Count() + " methods"); foreach (var method in methodBases) { LoggerInstance.Msg("Patched " + method.Name); } } } // I could not get this to work... // IL2CPP fucked it up beyond any recognition // Such a shame [HarmonyLib.HarmonyPatch] public class Patches { [HarmonyLib.HarmonyPrefix] [HarmonyLib.HarmonyPatch(typeof(FinancialReportSystem), "HandleMoneyUpdated")] public static void PrefixMoney(ref long __0) { // if (Global.Debug.Value) Console.WriteLine($"Money is {__0}"); if (__0 > 0) { __0 = (long)(__0 * Global.MoneyMultiplier.Value); if (Global.Debug.Value) Console.WriteLine($"Money modified to {__0}"); } } // [HarmonyLib.HarmonyPostfix] // [HarmonyLib.HarmonyPatch(typeof(TechTreeModel), nameof(TechTreeModel.GetBonusPeoplePerMinute))] // public static void PostfixPeoplePerMinute(ref float __result) { // __result *= Main.peoplePerMinuteMultiplier.Value; // __result += Main.peoplePerMinuteOffset.Value; // } } }