Refactor pause handling; implement GameBus for pause state management and update event popup behavior
This commit is contained in:
@@ -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.")]
|
||||
|
Reference in New Issue
Block a user