Skip to main content

Phase Class

Represents a phase in the game loop containing multiple passes. More...

Declaration

class helios::engine::runtime::gameloop::Phase { ... }

Friends Index

classhelios::engine::runtime::gameloop::GameLoop

Public Constructors Index

Phase (helios::engine::runtime::gameloop::GameLoop &gameloop)

Constructs a Phase with a reference to its owning GameLoop. More...

Public Member Functions Index

booladdPassCommitListener (PassCommitListener *passCommitListener)

Registers a listener to be notified when passes commit. More...

template <typename StateType>
Pass &addPass (const StateType t)

Creates and adds a new typed pass to this phase. More...

helios::engine::runtime::gameloop::GameLoop &gameLoop () noexcept

Returns a reference to the owning GameLoop. More...

Private Member Functions Index

voidinit (GameWorld &gameWorld)

Initializes all passes within this phase. More...

voidupdate (GameWorld &gameWorld, UpdateContext &updateContext)

Updates all passes within this phase. More...

boolnotifyPassCommitListeners (CommitPoint commitPoint, GameWorld &gameWorld, UpdateContext &updateContext)

Notifies all registered listeners about a pass commit. More...

Private Member Attributes Index

std::vector< PassCommitListener * >passCommitListeners_

Collection of listeners to be notified when a pass commits. More...

std::vector< std::unique_ptr< Pass > >passEntries_

Collection of passes belonging to this phase. More...

helios::engine::runtime::gameloop::GameLoop &gameloop_

Reference to the owning GameLoop. More...

Description

Represents a phase in the game loop containing multiple passes.

A Phase groups related systems into passes that are executed sequentially. Each pass can contain multiple systems and may have a commit point for event synchronization.

Commit points allow fine-grained control over when commands are flushed, managers are processed, and pass-level events are synchronized. See CommitPoint for available synchronization options.

Phases are owned by the GameLoop and should not be created directly.

See Also

Pass

See Also

CommitPoint

See Also

GameLoop

Definition at line 74 of file Phase.ixx.

Friends

helios::engine::runtime::gameloop::GameLoop

Public Constructors

Phase()

helios::engine::runtime::gameloop::Phase::Phase (helios::engine::runtime::gameloop::GameLoop & gameloop)
inline explicit

Constructs a Phase with a reference to its owning GameLoop.

Parameters
gameloop

Reference to the parent GameLoop.

Definition at line 178 of file Phase.ixx.

Public Member Functions

addPass()

template <typename StateType>
Pass & helios::engine::runtime::gameloop::Phase::addPass (const StateType t)
inline

Creates and adds a new typed pass to this phase.

The state parameter specifies in which states this pass should execute. Passes are skipped if the current state does not match the configured mask (using bitwise AND).

Template Parameters
StateType

The state enum type (e.g., GameState, MatchState).

Parameters
t

The state mask specifying when this pass should run.

Returns

Reference to the newly created Pass for method chaining.

See Also

TypedPass

See Also

Session::state()

Definition at line 231 of file Phase.ixx.

231 Pass& addPass(const StateType t) {// const helios::engine::mechanics::gamestate::types::GameState gameState = helios::engine::mechanics::gamestate::types::GameState::Any) {
232
233 auto entry = std::make_unique<TypedPass<StateType>>(*this, t);
234 auto* raw = entry.get();
235 passEntries_.emplace_back(std::move(entry));
236
237 return *raw;
238 }

addPassCommitListener()

bool helios::engine::runtime::gameloop::Phase::addPassCommitListener (PassCommitListener * passCommitListener)
inline

Registers a listener to be notified when passes commit.

The listener will receive notifications for all passes within this phase. The GameLoop typically registers itself to handle event synchronization, command buffer flushing, and manager processing based on commit point flags.

Duplicate registrations are prevented; attempting to add the same listener twice will return false and leave the listener list unchanged.

Parameters
passCommitListener

Pointer to the listener to register. Must remain valid for the lifetime of this Phase or until removed.

Returns

True if the listener was added, false if it was already registered.

See Also

PassCommitListener

See Also

notifyPassCommitListeners()

Definition at line 201 of file Phase.ixx.

201 bool addPassCommitListener(PassCommitListener* passCommitListener) {
202
203 for (int i = 0; i < passCommitListeners_.size(); i++) {
204 if (passCommitListeners_[i] == passCommitListener) {
205 return false;
206 }
207 }
208
209 passCommitListeners_.emplace_back(passCommitListener);
210
211 return true;
212 }

gameLoop()

helios::engine::runtime::gameloop::GameLoop & helios::engine::runtime::gameloop::Phase::gameLoop ()
inline nodiscard noexcept

Returns a reference to the owning GameLoop.

Returns

Reference to the parent GameLoop.

Definition at line 245 of file Phase.ixx.

246 return gameloop_;
247 }

Private Member Functions

init()

void helios::engine::runtime::gameloop::Phase::init (GameWorld & gameWorld)
inline

Initializes all passes within this phase.

Parameters
gameWorld

Reference to the game world.

Definition at line 98 of file Phase.ixx.

98 void init(GameWorld& gameWorld){
99 for (auto& pass : passEntries_) {
100 // every pass contains systems that are updated here
101 pass->init(gameWorld);
102 }
103 };

notifyPassCommitListeners()

bool helios::engine::runtime::gameloop::Phase::notifyPassCommitListeners (CommitPoint commitPoint, GameWorld & gameWorld, UpdateContext & updateContext)
inline

Notifies all registered listeners about a pass commit.

Called after each pass completes its update cycle. Each registered PassCommitListener receives the commit point flags, allowing it to perform the appropriate synchronization actions (event swapping, command flushing, manager processing).

Parameters
commitPoint

The CommitPoint flags from the completed pass.

gameWorld

The game world where the commit occured.

updateContext

The current update context.

Returns

Always returns true.

See Also

PassCommitListener::onPassCommit()

See Also

addPassCommitListener()

Definition at line 153 of file Phase.ixx.

153 bool notifyPassCommitListeners(CommitPoint commitPoint, GameWorld& gameWorld, UpdateContext& updateContext) {
154
155 for (const auto& passCommitListener : passCommitListeners_) {
156 passCommitListener->onPassCommit(commitPoint, gameWorld, updateContext);
157 }
158 return true;
159 }

update()

void helios::engine::runtime::gameloop::Phase::update (GameWorld & gameWorld, UpdateContext & updateContext)
inline

Updates all passes within this phase.

Iterates through all passes, updating their systems and then invoking the commit action based on the pass's configured CommitPoint. The commit point determines whether pass-level events are synchronized, the command buffer is flushed, or managers are processed.

Passes are conditionally executed based on their configured game state. A pass is only updated if its `runsIn()` state matches the current game state.

Parameters
gameWorld

The game world where the update occurred.

updateContext

The current update context.

gameState

The current game state used to filter pass execution.

See Also

CommitPoint

See Also

Pass::addCommitPoint()

See Also

Pass::runsIn()

Definition at line 124 of file Phase.ixx.

124 void update(GameWorld& gameWorld, UpdateContext& updateContext){
125
126 for (auto& pass : passEntries_) {
127
128 if (pass->shouldRun(updateContext)) {
129 pass->update(updateContext);
130 notifyPassCommitListeners(pass->commitPoint(), gameWorld, updateContext);
131 }
132
133 }
134 };

Private Member Attributes

gameloop_

helios::engine::runtime::gameloop::GameLoop& helios::engine::runtime::gameloop::Phase::gameloop_

Reference to the owning GameLoop.

Definition at line 169 of file Phase.ixx.

passCommitListeners_

std::vector<PassCommitListener*> helios::engine::runtime::gameloop::Phase::passCommitListeners_

Collection of listeners to be notified when a pass commits.

Listeners are notified after each pass completes, receiving the pass's configured CommitPoint flags. The GameLoop registers itself as a listener to handle event buffer swapping, command flushing, and manager processing based on the commit point configuration.

See Also

PassCommitListener

See Also

notifyPassCommitListeners()

Definition at line 89 of file Phase.ixx.

89 std::vector<PassCommitListener*> passCommitListeners_;

passEntries_

std::vector<std::unique_ptr<Pass> > helios::engine::runtime::gameloop::Phase::passEntries_

Collection of passes belonging to this phase.

Definition at line 164 of file Phase.ixx.

164 std::vector<std::unique_ptr<Pass>> passEntries_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.