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​

booladdPassEndListener (PassEndListener *passEndListener)

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

template <typename StateType>
Pass &beginPass (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...

boolnotifyPassEndListeners (Pass &pass, GameWorld &gameWorld, UpdateContext &updateContext)

Notifies all registered listeners about a pass reaching its end. More...

Private Member Attributes Index​

std::vector< PassEndListener * >passEndListeners_

Collection of listeners to be notified when a pass ends. 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.

See Also

Pass

See Also

GameLoop

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

148 explicit Phase(helios::engine::runtime::gameloop::GameLoop& gameloop, GameWorld& gameWorld) : gameloop_(gameloop), gameWorld_(gameWorld) {
149
150 }

Public Member Functions​

addPassEndListener()​

bool helios::engine::runtime::gameloop::Phase::addPassEndListener (PassEndListener * passEndListener)
inline

Registers a listener to be notified when passes end.

Parameters
passEndListener

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

PassEndListener

See Also

notifyPassEndListeners()

Definition at line 164 of file Phase.ixx.

165
166 for (int i = 0; i < passEndListeners_.size(); i++) {
167 if (passEndListeners_[i] == passEndListener) {
168 return false;
169 }
170 }
171
172 passEndListeners_.emplace_back(passEndListener);
173
174 return true;
175 }

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

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

beginPass()​

template <typename StateType>
Pass & helios::engine::runtime::gameloop::Phase::beginPass (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 195 of file Phase.ixx.

195 Pass& beginPass(const StateType t) {
196 auto entry = std::make_unique<TypedPass<StateType>>(*this, t, gameWorld_);
197 auto* raw = entry.get();
198 passEntries_.emplace_back(std::move(entry));
199
200 return *raw;
201 }

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

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

79 void init(GameWorld& gameWorld){
80 for (auto& pass : passEntries_) {
81 // every pass contains systems that are updated here
82 pass->init(gameWorld);
83 }
84 };

notifyPassEndListeners()​

bool helios::engine::runtime::gameloop::Phase::notifyPassEndListeners (Pass & pass, GameWorld & gameWorld, UpdateContext & updateContext)
inline

Notifies all registered listeners about a pass reaching its end.

Parameters
pass

The pass that reached its end.

gameWorld

The game world where the pass end occured.

updateContext

The current update context.

Returns

Always returns true.

See Also

PassEndListener::onPassCommit()

See Also

addPassEndListener()

Definition at line 120 of file Phase.ixx.

120 bool notifyPassEndListeners(Pass& pass, GameWorld& gameWorld, UpdateContext& updateContext) {
121
122 for (const auto& passEndListener : passEndListeners_) {
123 passEndListener->onPassEnd(pass, gameWorld, updateContext);
124 }
125 return true;
126 }

update()​

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

Updates all passes within this phase.

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

96 void update(GameWorld& gameWorld, UpdateContext& updateContext){
97
98 for (auto& pass : passEntries_) {
99
100 if (pass->shouldRun(updateContext)) {
101 pass->update(updateContext);
102 notifyPassEndListeners(*pass, gameWorld, updateContext);
103 }
104
105 }
106 };

Private Member Attributes​

gameloop_​

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

Reference to the owning GameLoop.

Definition at line 136 of file Phase.ixx.

gameWorld_​

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

Definition at line 138 of file Phase.ixx.

passEndListeners_​

std::vector<PassEndListener*> helios::engine::runtime::gameloop::Phase::passEndListeners_

Collection of listeners to be notified when a pass ends.

See Also

PassEndListener

See Also

notifyPassEndListeners()

Definition at line 72 of file Phase.ixx.

72 std::vector<PassEndListener*> passEndListeners_;

passEntries_​

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

Collection of passes belonging to this phase.

Definition at line 131 of file Phase.ixx.

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