From 21963d9013084b3c585f1151e25bad928d4194ad Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 28 Sep 2024 22:41:30 +0200 Subject: [PATCH] Add sunrise hour offset --- .../InfectionFreeZone/InfectionFreeZone.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs b/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs index 9ecfbc3..060802f 100644 --- a/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs +++ b/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs @@ -97,6 +97,7 @@ namespace InfectionFreeZone { public static ConfigEntry rotationTimestepMultiplier; public static ConfigEntry sunsetHourOffset; + public static ConfigEntry sunriseHourOffset; public static ConfigEntry productionProfitMultiplierDebug; public static ConfigEntry productionProfitMultiplier; @@ -164,6 +165,7 @@ namespace InfectionFreeZone { rotationTimestepMultiplier = Config.Bind("General", "Rotation Timestep Multiplier", 1f); sunsetHourOffset = Config.Bind("General", "Sunset Hour Offset", 0f); + sunriseHourOffset = Config.Bind("General", "Sunrise Hour Offset", 0f); productionProfitMultiplierDebug = Config.Bind("General", "Production Profit Multiplier Debug", false); productionProfitMultiplier = @@ -542,6 +544,17 @@ namespace InfectionFreeZone { return; __result += Main.sunsetHourOffset.Value; + __result = Mathf.Clamp(__result, 0f, 24f); + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(TimeController), "GetSunriseHour")] + public static void PostfixGetSunriseHour(ref float __result) { + if (Main.sunriseHourOffset.Value <= 0) + return; + + __result += Main.sunriseHourOffset.Value; + __result = Mathf.Clamp(__result, 0f, 24f); } [HarmonyPrefix]