Skip to content

Commit

Permalink
fix bug with respawning reverting temp player mods
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Is-Awesome committed Sep 9, 2024
1 parent aef297c commit 7f5ada7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 10 additions & 0 deletions Code/PlayerActionModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class PlayerActionModifier
public PlayerActionModifier()
{
Events.OnPlayerSpawn += OnPlayerSpawn;
Events.OnPlayerRespawn += OnPlayerRespawn;
ItemRandomizer.OnItemReceived += OnItemReceived;
}

Expand Down Expand Up @@ -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)
Expand Down
16 changes: 10 additions & 6 deletions Code/SceneLoadEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7f5ada7

Please sign in to comment.