From 4f22ed0c05b02e54bfab77c085f921784233c480 Mon Sep 17 00:00:00 2001 From: Ben H Date: Sun, 18 Aug 2024 15:45:59 -0400 Subject: [PATCH] 5.1.0 - if entering a new gamestate causes another game state switch, do the switch! --- .../BenMakesGames.PlayPlayMini.csproj | 2 +- BenMakesGames.PlayPlayMini/GameStateManager.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj b/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj index de78752..98df353 100644 --- a/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj +++ b/BenMakesGames.PlayPlayMini/BenMakesGames.PlayPlayMini.csproj @@ -5,7 +5,7 @@ Ben Hendel-Doying An opinionated framework for making smallish games with MonoGame. 2021-2024 Ben Hendel-Doying - 5.0.0 + 5.1.0 true monogame game engine framework di state diff --git a/BenMakesGames.PlayPlayMini/GameStateManager.cs b/BenMakesGames.PlayPlayMini/GameStateManager.cs index 8cf54b3..8631d6b 100644 --- a/BenMakesGames.PlayPlayMini/GameStateManager.cs +++ b/BenMakesGames.PlayPlayMini/GameStateManager.cs @@ -154,15 +154,15 @@ protected override void EndDraw() private void SwitchState() { - if(NextState is null) - return; - - CurrentState.Leave(); + while (NextState is not null) + { + CurrentState.Leave(); - CurrentState = NextState; - NextState = null; + CurrentState = NextState; + NextState = null; - CurrentState.Enter(); + CurrentState.Enter(); + } } public void ChangeState(GameState nextState)