Skip to main content

EngineFlowSystem Class Template

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

Declaration

template <typename TCommandBuffer> class helios::engine::runtime::enginestate::systems::EngineFlowSystem<TCommandBuffer> { ... }

Public Member Typedefs Index

template <typename TCommandBuffer>
usingEngineRoleTag = helios::engine::runtime::world::tags::SystemRole
template <typename TCommandBuffer>
usingCommandBuffer_type = TCommandBuffer

Public Member Functions Index

template <typename TCommandBuffer>
voidupdate (helios::engine::runtime::world::UpdateContext &updateContext, TCommandBuffer &buffer) noexcept

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

Private Member Attributes Index

template <typename TCommandBuffer>
EngineStateprevMatchState_ = EngineState::Undefined

The previously observed game state. More...

template <typename TCommandBuffer>
StateTransitionIdType< EngineState >prevEngineStateTransitionId_ = StateTransitionIdType<EngineState>::Undefined

The previously observed state transition ID. More...

Description

System that drives automatic game state transitions.

EngineFlowSystem monitors the current EngineState 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

EngineState

See Also

EngineStateTransitionId

See Also

StateCommand

Definition at line 48 of file EngineFlowSystem.ixx.

Public Member Typedefs

CommandBuffer_type

template <typename TCommandBuffer>
using helios::engine::runtime::enginestate::systems::EngineFlowSystem< TCommandBuffer >::CommandBuffer_type = TCommandBuffer

Definition at line 64 of file EngineFlowSystem.ixx.

EngineRoleTag

template <typename TCommandBuffer>
using helios::engine::runtime::enginestate::systems::EngineFlowSystem< TCommandBuffer >::EngineRoleTag = helios::engine::runtime::world::tags::SystemRole

Public Member Functions

update()

template <typename TCommandBuffer>
void helios::engine::runtime::enginestate::systems::EngineFlowSystem< TCommandBuffer >::update (helios::engine::runtime::world::UpdateContext & updateContext, TCommandBuffer & buffer)
inline noexcept

Updates the game flow and emits state transition commands.

Checks the current EngineState 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 75 of file EngineFlowSystem.ixx.

76
77 auto& session = updateContext.session();
78
79 const auto engineState = session.state<EngineState>();
80 auto engineStateTransitionId = session.stateTransitionId<EngineState>();
81
82 // only return if the state is undefined.
83 // in any other case, we allow to drive the state forward, even if
84 // the previous state is the same as the current one, in case any guard
85 // did veto the next state
86 if (engineState == EngineState::Undefined) {// && prevMatchState_ == engineState && prevEngineStateTransitionId_ == engineStateTransitionId) {
87 return;
88 }
89
90 prevMatchState_= engineState;
91 prevEngineStateTransitionId_ = engineStateTransitionId;
92
93 switch (engineState) {
94 case EngineState::Booting: {
95 buffer.template add<StateCommand<EngineState>>(
96 StateTransitionRequest<EngineState>(engineState, EngineStateTransitionId::BootRequest)
97 );
98 break;
99 }
100
101 case EngineState::Booted: {
102 buffer.template add<StateCommand<EngineState>>(
103 StateTransitionRequest<EngineState>(engineState, EngineStateTransitionId::WarmupRequest)
104 );
105 break;
106 }
107
108
109 default:
110 break;
111 }
112 }

Reference helios::engine::runtime::registerComponents.

Private Member Attributes

prevEngineStateTransitionId_

template <typename TCommandBuffer>
StateTransitionIdType<EngineState> helios::engine::runtime::enginestate::systems::EngineFlowSystem< TCommandBuffer >::prevEngineStateTransitionId_ = StateTransitionIdType<EngineState>::Undefined

The previously observed state transition ID.

Definition at line 58 of file EngineFlowSystem.ixx.

prevMatchState_

template <typename TCommandBuffer>
EngineState helios::engine::runtime::enginestate::systems::EngineFlowSystem< TCommandBuffer >::prevMatchState_ = EngineState::Undefined

The previously observed game state.

Definition at line 53 of file EngineFlowSystem.ixx.

53 EngineState prevMatchState_ = EngineState::Undefined;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.