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, GameWorld &gameWorld)

Constructs a Phase with references to GameLoop and GameWorld. 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...

helios::engine::runtime::world::GameWorld &gameWorld_

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, GameWorld & gameWorld)
inline explicit

Constructs a Phase with references to GameLoop and GameWorld.

Parameters
gameloop

Reference to the parent GameLoop.

gameWorld

Shared GameWorld used by passes in this phase.

Definition at line 180 of file Phase.ixx.

180 explicit Phase(helios::engine::runtime::gameloop::GameLoop& gameloop, GameWorld& gameWorld) : gameloop_(gameloop), gameWorld_(gameWorld) {
181
182 }

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). New passes are bound to this phase's GameWorld reference.

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 234 of file Phase.ixx.

234 Pass& addPass(const StateType t) {
235 auto entry = std::make_unique<TypedPass<StateType>>(*this, t, gameWorld_);
236 auto* raw = entry.get();
237 passEntries_.emplace_back(std::move(entry));
238
239 return *raw;
240 }

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

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 203 of file Phase.ixx.

204
205 for (int i = 0; i < passCommitListeners_.size(); i++) {
206 if (passCommitListeners_[i] == passCommitListener) {
207 return false;
208 }
209 }
210
211 passCommitListeners_.emplace_back(passCommitListener);
212
213 return true;
214 }

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

Referenced by helios::engine::runtime::gameloop::GameLoop::init.

gameLoop()

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

Returns a reference to the owning GameLoop.

Returns

Reference to the parent GameLoop.

Definition at line 247 of file Phase.ixx.

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 152 of file Phase.ixx.

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

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.

See Also

CommitPoint

See Also

Pass::addCommitPoint()

See Also

Pass::runsIn()

Definition at line 123 of file Phase.ixx.

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

Private Member Attributes

gameloop_

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

Reference to the owning GameLoop.

Definition at line 168 of file Phase.ixx.

gameWorld_

helios::engine::runtime::world::GameWorld& helios::engine::runtime::gameloop::Phase::gameWorld_

Definition at line 170 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 163 of file Phase.ixx.

163 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.9.8.