Add Melonpreferences

This commit is contained in:
2024-09-27 22:16:39 +02:00
parent 69eb2794ca
commit 86991edbd2
2 changed files with 36 additions and 9 deletions

View File

@@ -2,15 +2,25 @@
using System.Linq;
using Il2CppFunGI.ATTT.Game.Gameplay.FinancialReport;
using MelonLoader;
using UnityEngine;
namespace ArmsTradeTycoonTanks {
public static class Global {
public static bool Debug = true;
public static float MoneyMultiplier = 1.0f;
private static MelonPreferences_Category category;
public static MelonPreferences_Entry<bool> Debug;
public static MelonPreferences_Entry<float> MoneyMultiplier;
public static void InitializePreferences() {
category = MelonPreferences.CreateCategory("ArmsTradeTycoonTanks");
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 OnInitializeMelon() {
Global.InitializePreferences();
LoggerInstance.Msg("Phat Melon mod loaded");
HarmonyLib.Harmony harmony = HarmonyInstance;
harmony.PatchAll();
@@ -28,12 +38,12 @@ namespace ArmsTradeTycoonTanks {
[HarmonyLib.HarmonyPrefix]
[HarmonyLib.HarmonyPatch(typeof(FinancialReportSystem), "HandleMoneyUpdated")]
public static void PrefixMoney(ref long __0) {
if (Global.Debug)
Console.WriteLine($"Money is {__0}");
if (Global.Debug.Value)
Debug.Log($"Money is {__0}");
if (__0 > 0) {
__0 = (long)(__0 * Global.MoneyMultiplier);
if (Global.Debug)
Console.WriteLine($"Money modified to {__0}");
__0 = (long)(__0 * Global.MoneyMultiplier.Value);
if (Global.Debug.Value)
Debug.Log($"Money modified to {__0}");
}
}

View File

@@ -3,8 +3,10 @@
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<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_MANAGED>$(GAME_MELON)/Il2CppAssemblies</GAME_MANAGED>
<GAME_NET6>$(GAME_MELON)/net6</GAME_NET6>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DA9D274E-486F-4F82-84FF-CD9388CB0B09}</ProjectGuid>
@@ -57,6 +59,21 @@
<Reference Include="Il2CppFunGI">
<HintPath>$(GAME_MANAGED)/Il2CppATTT.Game.dll</HintPath>
</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>
<Reference Include="UrGUI">
<HintPath>$(GAME_USER_LIBS)/UrGUI.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
</Project>