new-horizons/NewHorizons/Patches/DetectorPatches/PlayerHazardDetectorPatches.cs
2023-08-31 15:27:11 -07:00

22 lines
710 B
C#

using HarmonyLib;
using NewHorizons.Utility.OWML;
namespace NewHorizons.Patches.DetectorPatches
{
[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);
}
}
}
}