using HarmonyLib; using ScheduleOne.Law; using ScheduleOne.PlayerScripts; using MelonLoader; namespace DohmStashRehydrated { public class PolicePatches { [HarmonyPatch(typeof(ScheduleOne.Police.PoliceOfficer))] [HarmonyPatch("Awake")] public class DisablePolicePatches { public static void Postfix(ScheduleOne.Police.PoliceOfficer __instance) { if (Core.policeDisabled) { MelonLogger.Msg($"[DohmStash] New police officer spawned, attempting to deactivate: {__instance.GetNameAddress()}"); try { __instance.Deactivate(); MelonLogger.Msg($"[DohmStash] Successfully deactivated new officer: {__instance.GetNameAddress()}"); } catch (System.Exception e) { MelonLogger.Error($"[DohmStash] Failed to deactivate new officer: {e}"); } } } } [HarmonyPatch(typeof(ScheduleOne.Law.LawManager))] [HarmonyPatch("PoliceCalled")] public class DisablePoliceDispatchPatch { public static bool Prefix(Player target, Crime crime) { if (Core.policeDisabled) { MelonLogger.Msg($"[DohmStash] Blocked police dispatch - police disabled. Target: {target.PlayerName}, Crime: {crime.GetType().Name}"); return false; } return true; } } [HarmonyPatch(typeof(ScheduleOne.PlayerScripts.PlayerCrimeData))] [HarmonyPatch("SetPursuitLevel")] public class DisablePursuitLevelPatch { public static bool Prefix(PlayerCrimeData.EPursuitLevel level) { if (Core.policeDisabled) { MelonLogger.Msg($"[DohmStash] Blocked pursuit level change - police disabled. Level: {level}"); return false; } return true; } } [HarmonyPatch(typeof(ScheduleOne.PlayerScripts.PlayerCrimeData))] [HarmonyPatch("AddCrime")] public class DisableCrimeRecordingPatch { public static bool Prefix(Crime crime, int quantity = 1) { if (Core.policeDisabled) { MelonLogger.Msg($"[DohmStash] Blocked crime recording - police disabled. Crime: {crime.GetType().Name}, Quantity: {quantity}"); return false; } return true; } } [HarmonyPatch(typeof(ScheduleOne.Police.PoliceOfficer))] [HarmonyPatch("CanInvestigate")] public class DisableInvestigationPatch { public static bool Prefix() { if (Core.policeDisabled) { MelonLogger.Msg("[DohmStash] Blocked police investigation - police disabled"); return false; } return true; } } [HarmonyPatch(typeof(ScheduleOne.Law.LawManager))] [HarmonyPatch("StartFootpatrol")] public class DisableFootPatrolPatch { public static bool Prefix() { if (Core.policeDisabled) { MelonLogger.Msg("[DohmStash] Blocked foot patrol start - police disabled"); return false; } return true; } } [HarmonyPatch(typeof(ScheduleOne.Law.LawManager))] [HarmonyPatch("StartVehiclePatrol")] public class DisableVehiclePatrolPatch { public static bool Prefix() { if (Core.policeDisabled) { MelonLogger.Msg("[DohmStash] Blocked vehicle patrol start - police disabled"); return false; } return true; } } [HarmonyPatch(typeof(ScheduleOne.Map.PoliceStation))] [HarmonyPatch("Dispatch")] public class DisablePoliceStationDispatchPatch { public static bool Prefix(int requestedOfficerCount, ScheduleOne.PlayerScripts.Player targetPlayer, ScheduleOne.Map.PoliceStation.EDispatchType type = ScheduleOne.Map.PoliceStation.EDispatchType.Auto, bool beginAsSighted = false) { if (Core.policeDisabled) { MelonLogger.Msg($"[DohmStash] Blocked police dispatch - police disabled. Target: {targetPlayer.PlayerName}, Type: {type}"); return false; } return true; } } [HarmonyPatch(typeof(ScheduleOne.Police.PoliceOfficer))] [HarmonyPatch("BeginFootPursuit_Networked")] public class DisableFootPursuitPatch { public static bool Prefix() { if (Core.policeDisabled) { MelonLogger.Msg("[DohmStash] Blocked foot pursuit - police disabled"); return false; } return true; } } [HarmonyPatch(typeof(ScheduleOne.Police.PoliceOfficer))] [HarmonyPatch("BeginVehiclePursuit_Networked")] public class DisableVehiclePursuitPatch { public static bool Prefix() { if (Core.policeDisabled) { MelonLogger.Msg("[DohmStash] Blocked vehicle pursuit - police disabled"); return false; } return true; } } [HarmonyPatch(typeof(ScheduleOne.Police.PoliceOfficer))] [HarmonyPatch("BeginBodySearch_Networked")] public class DisableBodySearchPatch { public static bool Prefix() { if (Core.policeDisabled) { MelonLogger.Msg("[DohmStash] Blocked body search - police disabled"); return false; } return true; } } [HarmonyPatch(typeof(ScheduleOne.NPCs.Actions.NPCActions))] [HarmonyPatch("CallPolice_Networked")] public class DisablePoliceCallPatch { public static bool Prefix() { if (Core.policeDisabled) { MelonLogger.Msg("[DohmStash] Blocked NPC police call - police disabled"); return false; } return true; } } } }