From 6847471536be1848793a62eecfcea25bb3aedf4d Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sat, 26 Nov 2022 15:45:16 -0500 Subject: [PATCH] simplify --- .../NH/SuckedIntoLavaByTornadoAchievement.cs | 8 ++++++-- NewHorizons/Patches/AchievementPatches.cs | 10 ---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/NewHorizons/OtherMods/AchievementsPlus/NH/SuckedIntoLavaByTornadoAchievement.cs b/NewHorizons/OtherMods/AchievementsPlus/NH/SuckedIntoLavaByTornadoAchievement.cs index 3d0d1efd..944e8362 100644 --- a/NewHorizons/OtherMods/AchievementsPlus/NH/SuckedIntoLavaByTornadoAchievement.cs +++ b/NewHorizons/OtherMods/AchievementsPlus/NH/SuckedIntoLavaByTornadoAchievement.cs @@ -13,11 +13,15 @@ namespace NewHorizons.OtherMods.AchievementsPlus.NH public static void Init() { AchievementHandler.Register(UNIQUE_ID, false, Main.Instance); + GlobalMessenger.AddListener("PlayerDeath", OnPlayerDeath); } - public static void Earn() + public static void OnPlayerDeath(DeathType deathType) { - AchievementHandler.Earn(UNIQUE_ID); + if (deathType == DeathType.Energy && Locator.GetPlayerDetector().GetComponent()._activeVolumes.Any(fluidVolume => fluidVolume is TornadoFluidVolume or TornadoBaseFluidVolume or HurricaneFluidVolume)) + { + AchievementHandler.Earn(UNIQUE_ID); + } } } } diff --git a/NewHorizons/Patches/AchievementPatches.cs b/NewHorizons/Patches/AchievementPatches.cs index 3b7ea097..92feb118 100644 --- a/NewHorizons/Patches/AchievementPatches.cs +++ b/NewHorizons/Patches/AchievementPatches.cs @@ -8,16 +8,6 @@ namespace NewHorizons.Patches [HarmonyPatch] public static class AchievementPatches { - [HarmonyPrefix] - [HarmonyPatch(typeof(DeathManager), nameof(DeathManager.KillPlayer))] - public static void DeathManager_KillPlayer(DeathType deathType) - { - if (deathType == DeathType.Energy && Locator.GetPlayerDetector().GetComponent()._activeVolumes.Any(fluidVolume => fluidVolume is TornadoFluidVolume or TornadoBaseFluidVolume or HurricaneFluidVolume)) - { - SuckedIntoLavaByTornadoAchievement.Earn(); - } - } - [HarmonyPrefix] [HarmonyPatch(typeof(ProbeDestructionDetector), nameof(ProbeDestructionDetector.FixedUpdate))] public static bool ProbeDestructionDetector_FixedUpdate(ProbeDestructionDetector __instance)