Add resource multiplier multiplier

This commit is contained in:
2024-09-28 00:40:13 +02:00
parent 10e8218d07
commit 2e4fe4e7e3
2 changed files with 63 additions and 59 deletions

View File

@@ -2,6 +2,7 @@
using System.Linq;
using BepInEx;
using BepInEx.Configuration;
using GameCustomization;
using HarmonyLib;
using HarmonyLib.Tools;
@@ -14,12 +15,12 @@ namespace InfectionFreeZone {
public static ConfigEntry<bool> debug;
public static ConfigEntry<float> moneyMultiplier;
public static ConfigEntry<float> resourceMultiplier;
public void Awake() {
debug = Config.Bind("General", "Debug", false);
moneyMultiplier = Config.Bind("General", "MoneyMultiplier", 1f);
resourceMultiplier = Config.Bind("General", "ResourceMultiplier", 1f);
Logger.LogInfo("Cyka mod loaded");
HarmonyFileLog.Enabled = true;
@@ -33,19 +34,19 @@ namespace InfectionFreeZone {
}
}
// [HarmonyPatch]
// public class Patches {
// [HarmonyPrefix]
// [HarmonyPatch(typeof(TavernModel), "ChangeMoney")]
// public static void PrefixMoney(ref int value) {
// if (Main.debug.Value)
// Console.WriteLine($"Money is {value}");
// if (value > 0) {
// value = (int)(value * Main.moneyMultiplier.Value);
// if (Main.debug.Value)
// Console.WriteLine($"Money modified to {value}");
// }
// }
[HarmonyPatch]
public class Patches {
[HarmonyPrefix]
[HarmonyPatch(typeof(GameCustomize), "LoadResourcesSettings")]
public static void PostfixResourceMultiplier(ref float multiplier) {
if (Main.debug.Value)
Console.WriteLine($"Resource multiplier is {multiplier}");
if (multiplier > 0) {
multiplier = (int)(multiplier * Main.resourceMultiplier.Value);
if (Main.debug.Value)
Console.WriteLine($"Resource multiplier modified to {multiplier}");
}
}
//
// [HarmonyPrefix]
// [HarmonyPatch(typeof(UiController), "ChangeGameSpeed")]
@@ -89,5 +90,5 @@ namespace InfectionFreeZone {
// Console.WriteLine($"Quality modified to {__result}");
// }
// }
// }
}
}

View File

@@ -57,6 +57,9 @@
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(GAME_MANAGED)/UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="Ifz">
<HintPath>$(GAME_MANAGED)/Ifz.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
</Project>