Work speed no workey :(

This commit is contained in:
2024-09-28 01:06:35 +02:00
parent b36d7717eb
commit 8eaaaadcd0

View File

@@ -20,14 +20,14 @@ namespace InfectionFreeZone {
public static ConfigEntry<float> resourceMultiplier;
public static ConfigEntry<float> resourceGatheringMultiplier;
public static ConfigEntry<float> workSpeedMultiplier;
// public static ConfigEntry<float> 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<float>("_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<float>("_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