Skip to main content

DefaultMatchStateTransitionGuards Class

Provides default guard functions for match state transitions. More...

Declaration

class helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards { ... }

Public Static Functions Index

static boolisPlayerActive (helios::engine::runtime::world::UpdateContext &updateContext, const StateTransitionRequest< MatchState > transitionRequest)

Guard that allows transition only if the player is active. More...

static boolisPlayerInactive (helios::engine::runtime::world::UpdateContext &updateContext, const StateTransitionRequest< MatchState > transitionRequest)

Guard that allows transition only if the player is inactive. More...

static boolhasLifeLeft (helios::engine::runtime::world::UpdateContext &updateContext, const StateTransitionRequest< MatchState > transitionRequest)

Guard that allows transition only if the player has lives left. More...

static boolhasNoLifeLeft (helios::engine::runtime::world::UpdateContext &updateContext, const StateTransitionRequest< MatchState > transitionRequest)

Guard that allows transition only if the player has no lives left. More...

Description

Provides default guard functions for match state transitions.

Guard functions are predicates that determine whether a state transition is allowed. They are evaluated before a transition occurs and can block it by returning false.

All guards are static functions that take an UpdateContext and a MatchStateTransitionRequest, returning true if the transition is allowed.

See Also

MatchStateTransitionRequest

See Also

MatchStateManager

Definition at line 39 of file DefaultMatchStateTransitionGuards.ixx.

Public Static Functions

hasLifeLeft()

bool helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::hasLifeLeft (helios::engine::runtime::world::UpdateContext & updateContext, const StateTransitionRequest< MatchState > transitionRequest)
inline static

Guard that allows transition only if the player has lives left.

Parameters
updateContext

The current frame's update context.

transitionRequest

The requested state transition.

Returns

True if the player entity has lives left.

Definition at line 85 of file DefaultMatchStateTransitionGuards.ixx.

85 static bool hasLifeLeft(
87 const StateTransitionRequest<MatchState> transitionRequest
88 ) {
89 auto playerOpt = updateContext.find(updateContext.session().playerEntityHandle());
90 if (!playerOpt) {
91 return false;
92 }
93 auto* lc = playerOpt->get<LivesComponent>();
94 return lc && lc->lives() > 0;
95
96 }

References helios::engine::runtime::world::UpdateContext::find, helios::engine::mechanics::match::components::LivesComponent::lives, helios::engine::runtime::world::Session::playerEntityHandle and helios::engine::runtime::world::UpdateContext::session.

Referenced by hasNoLifeLeft.

hasNoLifeLeft()

bool helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::hasNoLifeLeft (helios::engine::runtime::world::UpdateContext & updateContext, const StateTransitionRequest< MatchState > transitionRequest)
inline static

Guard that allows transition only if the player has no lives left.

Parameters
updateContext

The current frame's update context.

transitionRequest

The requested state transition.

Returns

True if the player entity has no lives left.

See Also

hasLifeLeft

Definition at line 108 of file DefaultMatchStateTransitionGuards.ixx.

108 static bool hasNoLifeLeft(
110 const StateTransitionRequest<MatchState> transitionRequest
111 ) {
112 return !hasLifeLeft(updateContext, transitionRequest);
113 }

Reference hasLifeLeft.

isPlayerActive()

bool helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::isPlayerActive (helios::engine::runtime::world::UpdateContext & updateContext, const StateTransitionRequest< MatchState > transitionRequest)
inline static

Guard that allows transition only if the player is active.

Parameters
updateContext

The current frame's update context.

transitionRequest

The requested state transition.

Returns

True if the player entity exists and is active.

Definition at line 51 of file DefaultMatchStateTransitionGuards.ixx.

51 static bool isPlayerActive(
53 const StateTransitionRequest<MatchState> transitionRequest
54 ) {
55 auto playerOpt = updateContext.find(updateContext.session().playerEntityHandle());
56 return playerOpt.has_value() && playerOpt->isActive();
57
58 }

References helios::engine::runtime::world::UpdateContext::find, helios::engine::runtime::world::Session::playerEntityHandle and helios::engine::runtime::world::UpdateContext::session.

isPlayerInactive()

bool helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::isPlayerInactive (helios::engine::runtime::world::UpdateContext & updateContext, const StateTransitionRequest< MatchState > transitionRequest)
inline static

Guard that allows transition only if the player is inactive.

Parameters
updateContext

The current frame's update context.

transitionRequest

The requested state transition.

Returns

True if the player entity exists and is inactive.

Definition at line 68 of file DefaultMatchStateTransitionGuards.ixx.

68 static bool isPlayerInactive(
70 const StateTransitionRequest<MatchState> transitionRequest
71 ) {
72 auto playerOpt = updateContext.find(updateContext.session().playerEntityHandle());
73 return playerOpt.has_value() && !playerOpt->isActive();
74
75 }

References helios::engine::runtime::world::UpdateContext::find, helios::engine::runtime::world::Session::playerEntityHandle and helios::engine::runtime::world::UpdateContext::session.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.