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 43 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 68 of file GameFlowSystem.ixx.

69
70 auto& session = updateContext.session();
71
72 const auto gameState = session.state<GameState>();
73 auto gameStateTransitionId = session.stateTransitionId<GameState>();
74
75 // only return if the state is undefined.
76 // in any other case, we allow to drive the state forward, even if
77 // the previous state is the same as the current one, in case any guard
78 // did veto the next state
79 if (gameState == GameState::Undefined) {// && prevMatchState_ == gameState && prevGameStateTransitionId_ == gameStateTransitionId) {
80 return;
81 }
82
83 prevMatchState_= gameState;
84 prevGameStateTransitionId_ = gameStateTransitionId;
85
86 switch (gameState) {
87
89 updateContext.queueCommand<StateCommand<GameState>>(
91 );
92 break;
93 }
94
96 updateContext.queueCommand<StateCommand<GameState>>(
98 );
99 break;
100 }
101
103 updateContext.queueCommand<StateCommand<GameState>>(
105 );
106 break;
107 }
108
109 default:
110 break;
111 }
112 }

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

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 53 of file GameFlowSystem.ixx.

prevMatchState_

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

The previously observed game state.

Definition at line 48 of file GameFlowSystem.ixx.

48 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.