Game State System
Source: client/engine/systems/SystemsFunctions/GameStateSystem.cpp
Purpose: Handle scene transitions by calling DestroyScene and InitScene hooks when the next state changes.
Components used:
SceneManagement(current, next, scenes:std::unordered_map<std::string, std::shared_ptr<Scene_A>>)
Behavior
- Skip if
nextis empty or identical tocurrent. - If the current scene exists in
scenes, callDestroyScene(reg)to clean up the outgoing state. - If the target scene exists in
scenes, callInitScene(reg)to initialize the new state. - Update
currentwithnext, then resetnextto an empty string to avoid unintended reloads.
Main signature
void GameStateSystem(Eng::registry ®,
Eng::sparse_array<Component::SceneManagement> &sceneManagements);
Notes
Scene_Adefines theInitSceneandDestroyScenehooks invoked by this system.- The
scenesmap must be prefilled with available scenes and their keys. nextmust be set by other logic (UI, network, scripts) before this system runs so the transition occurs during the pass.