From 7f5ada7d4c09f197b7025c9838a3040c5c1b5f39 Mon Sep 17 00:00:00 2001 From: Chris-Is-Awesome <34765277+Chris-Is-Awesome@users.noreply.github.com> Date: Sun, 8 Sep 2024 21:21:08 -0700 Subject: [PATCH] fix bug with respawning reverting temp player mods --- Code/PlayerActionModifier.cs | 10 ++++++++++ Code/SceneLoadEvents.cs | 16 ++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Code/PlayerActionModifier.cs b/Code/PlayerActionModifier.cs index d4c032a..6233d6a 100644 --- a/Code/PlayerActionModifier.cs +++ b/Code/PlayerActionModifier.cs @@ -9,6 +9,7 @@ public class PlayerActionModifier public PlayerActionModifier() { Events.OnPlayerSpawn += OnPlayerSpawn; + Events.OnPlayerRespawn += OnPlayerRespawn; ItemRandomizer.OnItemReceived += OnItemReceived; } @@ -71,6 +72,15 @@ private void OnPlayerSpawn(Entity player, UnityEngine.GameObject camera, PlayerC DoModifyRoll(true); } + private void OnPlayerRespawn() + { + if (DisableStick) + DoModifiyStick(true); + + if (DisableRoll) + DoModifyRoll(true); + } + private void OnItemReceived(ItemHandler.ItemData.Item item, string sentFromPlayerName) { if (stickDisabler != null && item.Type == ItemHandler.ItemTypes.Melee) diff --git a/Code/SceneLoadEvents.cs b/Code/SceneLoadEvents.cs index 17e1388..ec65349 100644 --- a/Code/SceneLoadEvents.cs +++ b/Code/SceneLoadEvents.cs @@ -17,8 +17,9 @@ private bool DoGiveTempEFCS if (!settings.IncludeSuperSecrets) return false; + // Require Fire Mace and Fake EFCS Entity player = ModCore.Utility.GetPlayer(); - return player.GetStateVariable("melee") == 2 || player.GetStateVariable("fakeEFCS") > 0; + return player.GetStateVariable("melee") == 2 && player.GetStateVariable("fakeEFCS") > 0; } } @@ -34,12 +35,14 @@ public SceneLoadEvents(RandomizerSettings settings) { this.settings = settings; Events.OnSceneLoaded += OnSceneLoaded; + Events.OnPlayerRespawn += OnPlayerRespawn; ItemRandomizer.OnItemReceived += OnItemReceieved; } public void DoDisable() { Events.OnSceneLoaded -= OnSceneLoaded; + Events.OnPlayerRespawn -= OnPlayerRespawn; ItemRandomizer.OnItemReceived -= OnItemReceieved; } @@ -126,11 +129,6 @@ private void OverrideSpawnPoints() private void GiveTempEFCS() { Entity player = ModCore.Utility.GetPlayer(); - - // Require Fire Mace and Fake EFCS - if (player.GetStateVariable("melee") < 2 || player.GetStateVariable("fakeEFCS") < 1) - return; - player.AddLocalTempVar("melee"); player.SetStateVariable("melee", 3); } @@ -264,6 +262,12 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) OverrideSpawnPoints(); } + private void OnPlayerRespawn() + { + if (SceneName == "Deep19s" && DoGiveTempEFCS) + GiveTempEFCS(); + } + private void OnItemReceieved(ItemHandler.ItemData.Item item, string sentFromPlayerName) { if ((item.Type == ItemHandler.ItemTypes.Melee || item.Type == ItemHandler.ItemTypes.EFCS) && SceneName == "Deep19s" && DoGiveTempEFCS)