Creates a new StateManager instance.
OptionalinitialSceneId: string | null = nullInitial scene ID
Gets all game variables.
Copy of all variables
Gets the current scene ID.
The ID of the currently active scene, or null if none
Sets the current scene ID and adds previous scene to history.
The scene ID to set
Gets a copy of the scene navigation history.
The history contains scene IDs in the order they were visited, with the most recently visited scene at the end.
Array of previously visited scene IDs
Gets a shallow copy of the current game state.
This returns a copy to prevent external mutation of the internal state. Useful for save functionality or debugging.
A copy of the current game state
Clears the scene navigation history.
This can be useful when starting a new game or when you don't want players to be able to navigate back to previous scenes.
Gets a game variable.
Variable name
The variable value, or undefined if not set
Sets a game variable.
Variable name
Variable value
Manages game state including variables and scene history.
The StateManager handles all persistent game state, including:
State is stored in memory and can be accessed for save/load functionality.
StateManager
Example