From 8eaaaadcd0ff23f69feefe24d196a7eb9e1b3716 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 28 Sep 2024 01:06:35 +0200 Subject: [PATCH] Work speed no workey :( --- .../InfectionFreeZone/InfectionFreeZone.cs | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs b/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs index 2e54188..5ee568f 100644 --- a/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs +++ b/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs @@ -20,14 +20,14 @@ namespace InfectionFreeZone { public static ConfigEntry resourceMultiplier; public static ConfigEntry resourceGatheringMultiplier; - public static ConfigEntry workSpeedMultiplier; + // public static ConfigEntry workSpeedMultiplier; public void Awake() { debug = Config.Bind("General", "Debug", false); resourceMultiplier = Config.Bind("General", "ResourceMultiplier", 1f); resourceGatheringMultiplier = Config.Bind("General", "ResourceGatheringMultiplier", 1f); - workSpeedMultiplier = Config.Bind("General", "WorkSpeedMultiplier", 1f); + // workSpeedMultiplier = Config.Bind("General", "WorkSpeedMultiplier", 1f); Logger.LogInfo("Cyka mod loaded"); HarmonyFileLog.Enabled = true; @@ -67,24 +67,26 @@ namespace InfectionFreeZone { } } - [HarmonyPrefix] - [HarmonyPatch(typeof(WorkBase), "SetProgress")] - public static void PostfixSetProgress(WorkBase __instance, ref float progress) { - if (Main.debug.Value) - Console.WriteLine($"Progress is {progress}"); - if (progress > 0) { - var traversed = Traverse.Create(__instance); - var _previousProgress = traversed.Field("_previousProgress"); - var delta = progress - _previousProgress.Value; - - if (Main.debug.Value) - Console.WriteLine($"Delta is {delta}"); - - progress += delta * Main.workSpeedMultiplier.Value; - if (Main.debug.Value) - Console.WriteLine($"Progress modified to {progress}"); - } - } + // [HarmonyPrefix] + // [HarmonyPatch(typeof(WorkBase), "SetProgress")] + // public static void PostfixSetProgress(WorkBase __instance, ref float progress) { + // if (Main.debug.Value) + // Console.WriteLine($"Progress is {progress}"); + // if (progress > 0) { + // var traversed = Traverse.Create(__instance); + // var _previousProgress = traversed.Field("_previousProgress"); + // if (Main.debug.Value) + // Console.WriteLine($"_previousProgress is {_previousProgress}"); + // + // var delta = progress - _previousProgress.Value; + // if (Main.debug.Value) + // Console.WriteLine($"Delta is {delta}"); + // + // progress += delta * Main.workSpeedMultiplier.Value; + // if (Main.debug.Value) + // Console.WriteLine($"Progress modified to {progress}"); + // } + // } // Maybe prefix this with __instance // And then calculate the delta and update progress with progress+delta