diff --git a/NewHorizons/Patches/PlayerPatches/PlayerHazardDetectorPatches.cs b/NewHorizons/Patches/PlayerPatches/PlayerHazardDetectorPatches.cs new file mode 100644 index 00000000..032f8f9b --- /dev/null +++ b/NewHorizons/Patches/PlayerPatches/PlayerHazardDetectorPatches.cs @@ -0,0 +1,21 @@ +using HarmonyLib; +using NewHorizons.Utility.OWML; + +namespace NewHorizons.Patches.PlayerPatches +{ + [HarmonyPatch(typeof(HazardDetector))] + public static class PlayerHazardDetectorPatches + { + [HarmonyPostfix] + [HarmonyPatch(nameof(HazardDetector.Awake))] + public static void HazardDetector_Awake(HazardDetector __instance) + { + // Prevent the player detector from being hurt while the solar system is being set up + if (__instance._isPlayerDetector && !Main.IsSystemReady) + { + __instance.enabled = false; + Delay.RunWhen(() => Main.IsSystemReady, () => __instance.enabled = true); + } + } + } +}