Compare commits

...

3 Commits

Author SHA1 Message Date
6dbbf5a9b9 Give up 2024-09-27 23:48:37 +02:00
96ac1e3bc2 Fix improperly loading preferences 2024-09-27 23:06:12 +02:00
86991edbd2 Add Melonpreferences 2024-09-27 22:21:06 +02:00
2 changed files with 46 additions and 10 deletions

View File

@@ -1,15 +1,28 @@
using System; using System.Linq;
using System.Linq;
using Il2CppFunGI.ATTT.Game.Gameplay.FinancialReport; using Il2CppFunGI.ATTT.Game.Gameplay.FinancialReport;
using Il2CppSystem;
using MelonLoader; using MelonLoader;
using UnityEngine;
namespace ArmsTradeTycoonTanks { namespace ArmsTradeTycoonTanks {
public static class Global { public static class Global {
public static bool Debug = true; private static MelonPreferences_Category category;
public static float MoneyMultiplier = 1.0f; public static MelonPreferences_Entry<bool> Debug;
public static MelonPreferences_Entry<float> 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 class ArmsTradeTycoonTanksMelonMod : MelonMod {
public override void OnApplicationStart() {
Global.InitializePreferences();
}
public override void OnInitializeMelon() { public override void OnInitializeMelon() {
LoggerInstance.Msg("Phat Melon mod loaded"); LoggerInstance.Msg("Phat Melon mod loaded");
HarmonyLib.Harmony harmony = HarmonyInstance; HarmonyLib.Harmony harmony = HarmonyInstance;
@@ -23,20 +36,23 @@ namespace ArmsTradeTycoonTanks {
} }
} }
// I could not get this to work...
// IL2CPP fucked it up beyond any recognition
// Such a shame
[HarmonyLib.HarmonyPatch] [HarmonyLib.HarmonyPatch]
public class Patches { public class Patches {
[HarmonyLib.HarmonyPrefix] [HarmonyLib.HarmonyPrefix]
[HarmonyLib.HarmonyPatch(typeof(FinancialReportSystem), "HandleMoneyUpdated")] [HarmonyLib.HarmonyPatch(typeof(FinancialReportSystem), "HandleMoneyUpdated")]
public static void PrefixMoney(ref long __0) { public static void PrefixMoney(ref long __0) {
if (Global.Debug) // if (Global.Debug.Value)
Console.WriteLine($"Money is {__0}"); Console.WriteLine($"Money is {__0}");
if (__0 > 0) { if (__0 > 0) {
__0 = (long)(__0 * Global.MoneyMultiplier); __0 = (long)(__0 * Global.MoneyMultiplier.Value);
if (Global.Debug) if (Global.Debug.Value)
Console.WriteLine($"Money modified to {__0}"); Console.WriteLine($"Money modified to {__0}");
} }
} }
// [HarmonyLib.HarmonyPostfix] // [HarmonyLib.HarmonyPostfix]
// [HarmonyLib.HarmonyPatch(typeof(TechTreeModel), nameof(TechTreeModel.GetBonusPeoplePerMinute))] // [HarmonyLib.HarmonyPatch(typeof(TechTreeModel), nameof(TechTreeModel.GetBonusPeoplePerMinute))]
// public static void PostfixPeoplePerMinute(ref float __result) { // public static void PostfixPeoplePerMinute(ref float __result) {

View File

@@ -3,8 +3,10 @@
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup> <PropertyGroup>
<GAME_DIR>C:/Games/Arms Trade Tycoon Tanks</GAME_DIR> <GAME_DIR>C:/Games/Arms Trade Tycoon Tanks</GAME_DIR>
<GAME_USER_LIBS>$(GAME_DIR)/UserLibs</GAME_USER_LIBS>
<GAME_MELON>$(GAME_DIR)/MelonLoader</GAME_MELON> <GAME_MELON>$(GAME_DIR)/MelonLoader</GAME_MELON>
<GAME_MANAGED>$(GAME_MELON)/Il2CppAssemblies</GAME_MANAGED> <GAME_MANAGED>$(GAME_MELON)/Il2CppAssemblies</GAME_MANAGED>
<GAME_NET6>$(GAME_MELON)/net6</GAME_NET6>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DA9D274E-486F-4F82-84FF-CD9388CB0B09}</ProjectGuid> <ProjectGuid>{DA9D274E-486F-4F82-84FF-CD9388CB0B09}</ProjectGuid>
@@ -51,12 +53,30 @@
<Reference Include="UnityEngine"> <Reference Include="UnityEngine">
<HintPath>$(GAME_MANAGED)/UnityEngine.dll</HintPath> <HintPath>$(GAME_MANAGED)/UnityEngine.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine">
<HintPath>$(GAME_MANAGED)/UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>$(GAME_MANAGED)/UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule"> <Reference Include="UnityEngine.CoreModule">
<HintPath>$(GAME_MANAGED)/UnityEngine.CoreModule.dll</HintPath> <HintPath>$(GAME_MANAGED)/UnityEngine.CoreModule.dll</HintPath>
</Reference> </Reference>
<Reference Include="Il2CppFunGI"> <Reference Include="Il2CppFunGI">
<HintPath>$(GAME_MANAGED)/Il2CppATTT.Game.dll</HintPath> <HintPath>$(GAME_MANAGED)/Il2CppATTT.Game.dll</HintPath>
</Reference> </Reference>
<Reference Include="Il2CppSystem">
<HintPath>$(GAME_MANAGED)/Il2CppSystem.dll</HintPath>
</Reference>
<Reference Include="Il2Cppmscorlib">
<HintPath>$(GAME_MANAGED)/Il2Cppmscorlib.dll</HintPath>
</Reference>
<Reference Include="Il2CppInterop.Runtime">
<HintPath>$(GAME_NET6)/Il2CppInterop.Runtime.dll</HintPath>
</Reference>
<Reference Include="Il2CppInterop.Common">
<HintPath>$(GAME_NET6)/Il2CppInterop.Common.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
</Project> </Project>