Skip to main content

GameFlowSystem Class

System that drives automatic game state transitions. More...

Declaration

class helios::engine::mechanics::gamestate::systems::GameFlowSystem { ... }

Public Member Typedefs Index

usingEngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions Index

voidupdate (helios::engine::runtime::world::UpdateContext &updateContext) noexcept

Updates the game flow and emits state transition commands. More...

Private Member Attributes Index

GameStateprevMatchState_ = GameState::Undefined

The previously observed game state. More...

StateTransitionIdType< GameState >prevGameStateTransitionId_ = StateTransitionIdType<GameState>::Undefined

The previously observed state transition ID. More...

Description

System that drives automatic game state transitions.

GameFlowSystem monitors the current GameState and issues StateCommands to advance the state machine when appropriate. It tracks the previous state and transition ID to avoid emitting duplicate commands.

Typical flow: Undefined -> Start -> Title.

See Also

GameState

See Also

GameStateTransitionId

See Also

StateCommand

Definition at line 44 of file GameFlowSystem.ixx.

Public Member Typedefs

EngineRoleTag

using helios::engine::mechanics::gamestate::systems::GameFlowSystem::EngineRoleTag = helios::engine::common::tags::SystemRole

Public Member Functions

update()

void helios::engine::mechanics::gamestate::systems::GameFlowSystem::update (helios::engine::runtime::world::UpdateContext & updateContext)
inline noexcept

Updates the game flow and emits state transition commands.

Checks the current GameState from the session and compares it with the previously observed state. If a transition is required, a StateCommand is added to the command buffer.

Parameters
updateContext

The update context providing session and command buffer access.

Definition at line 69 of file GameFlowSystem.ixx.

70
71 auto& session = updateContext.session();
72
73 const auto gameState = session.state<GameState>();
74 auto gameStateTransitionId = session.stateTransitionId<GameState>();
75
76 if (gameState != GameState::Undefined && prevMatchState_ == gameState && prevGameStateTransitionId_ == gameStateTransitionId) {
77 return;
78 }
79
80 prevMatchState_= gameState;
81 prevGameStateTransitionId_ = gameStateTransitionId;
82
83 switch (gameState) {
84
86 updateContext.queueCommand<StateCommand<GameState>>(
88 );
89 break;
90 }
91
93 updateContext.queueCommand<StateCommand<GameState>>(
95 );
96 break;
97 }
98
100 updateContext.queueCommand<StateCommand<GameState>>(
102 );
103 break;
104 }
105
106
107 default:
108 break;
109 }
110 }

References helios::engine::mechanics::gamestate::types::Booted, helios::engine::mechanics::gamestate::types::BootRequest, helios::engine::mechanics::gamestate::types::MatchReady, helios::engine::mechanics::gamestate::types::StartMatchRequest, helios::engine::mechanics::gamestate::types::TitleRequest and helios::engine::mechanics::gamestate::types::Undefined.

Private Member Attributes

prevGameStateTransitionId_

StateTransitionIdType<GameState> helios::engine::mechanics::gamestate::systems::GameFlowSystem::prevGameStateTransitionId_ = StateTransitionIdType<GameState>::Undefined

The previously observed state transition ID.

Definition at line 54 of file GameFlowSystem.ixx.

prevMatchState_

GameState helios::engine::mechanics::gamestate::systems::GameFlowSystem::prevMatchState_ = GameState::Undefined

The previously observed game state.

Definition at line 49 of file GameFlowSystem.ixx.

49 GameState prevMatchState_ = GameState::Undefined;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.