Refactor pause handling; implement GameBus for pause state management and update event popup behavior

This commit is contained in:
2025-08-24 00:37:06 +02:00
parent 6d8139fd44
commit 1b3657b03a
5 changed files with 101 additions and 5 deletions

View File

@@ -32,6 +32,7 @@ public partial class GameBus : Node
public event Action PopulationVisualsUpdated;
public event Action<string> AgeAdvanced;
public event Action GameWon;
public event Action<bool> PauseStateChanged;
public override void _EnterTree()
{
@@ -133,12 +134,18 @@ public partial class GameBus : Node
{
effect.Execute(_gameState);
}
GetTree().Paused = false;
SetPause(false);
}
public void SubscribeToStat(Stat stat, Action<double> listener) => _gameState.Subscribe(stat, listener);
public void UnsubscribeFromStat(Stat stat, Action<double> listener) => _gameState.Unsubscribe(stat, listener);
public void SetPause(bool isPaused)
{
GetTree().Paused = isPaused;
PauseStateChanged?.Invoke(isPaused);
}
public GameState CurrentState => _gameState;
[ConsoleCommand("set_stat", "Sets the value of a specified stat.")]