Engine > Managers > Session Manager

Manages session-level state as the single access point for phase transitions, game settings, and player resources. Phases and systems must use this manager rather than reading or writing session state on GameState directly.

init

Initialises session state from settings and resets phase to IDLE. Called by initializers at the start of a new or loaded game. currentPlayerId is set to the last player so that the first incrementPlayer call in TURN_NEXT_PLAYER wraps to index 0, starting the turn cycle from the beginning of the player array regardless of player type order.

getPhase

Returns the current game phase.

setPhase

Transitions the game to a new phase.

setActiveEntity

Stores the entity selected for a unit command. Called by IdlePhase when transitioning into ENTITY_COMMAND so EntityCommandPhase can read it on follow-up actions.

getActiveEntity

Returns the currently active entity, or null if none is set.

getTurn

Returns the current turn number.

incrementPlayer

Advances to the next player in the players array, wrapping back to the start at the end.

incrementTurn

Increments the turn counter by one.

getPlayers

Returns all players for the current session.

getCurrentPlayer

Returns the current player, or undefined if not found.

serialize

Returns a snapshot of session state. Called by SaveGame to persist the current session. Eventually each manager will contribute its own slice.

deserialize

Restores session state from a saved snapshot. Called by LoadGame after the snapshot is fetched and validated.




© Gamesanova 2026