Skip to main content

Session Class

Holds session-level state for the current game instance. More...

Declaration

class helios::engine::runtime::world::Session { ... }

Private Member Typedefs Index

usingHandle_type = GameObject::Handle_type

Public Constructors Index

Session (const GameObject go)

Constructs a session with the given GameObject. More...

Public Member Functions Index

boolisInitialized () const noexcept
boolinitialize () noexcept
boolisDestroyed () noexcept
voiddestroy () noexcept
voidsetPlayerEntityHandle (const Handle_type go) noexcept

Sets the player entity handle. More...

Handle_typeplayerEntityHandle () const noexcept

Returns the player entity handle. More...

voidreset ()

Resets the session state. More...

template <typename StateType>
voidsetStateFrom (const StateTransitionContext< StateType > stateTransitionContext) noexcept

Updates state from a transition context. More...

template <typename StateType>
StateTypestate () const noexcept

Returns the current state for a given state type. More...

template <typename StateType>
StateTypestateFrom () const noexcept

Returns the source state of the last transition. More...

template <typename StateType>
auto stateTransitionId () const noexcept -> StateTransitionIdType< StateType >

Returns the last transition ID for a given state type. More...

template <typename StateType>
voidtrackState ()

Lets this session track the specified StateType. More...

voidsetViewportHandles (std::span< const ViewportHandle > &viewportHandles) noexcept

Replaces the active viewport IDs with the provided list. More...

std::span< const ViewportHandle >viewportHandles () const noexcept

Returns the currently active viewport handles. More...

boolisActiveViewport (const ViewportHandle viewportHandle) const noexcept

Returns true if the specified ViewportHandle is currently active. More...

voidclearViewportHandles () noexcept

Clears all active viewport handles. More...

Private Member Attributes Index

GameObjectgameObject_

The underlying GameObject storing session components. More...

Handle_typeplayerEntity_

Handle to the player entity. More...

Description

Holds session-level state for the current game instance.

The Session wraps a GameObject that stores session-related components using the template-based state system. It provides type-safe accessors for any registered state type (e.g., GameState, MatchState).

State types must be registered via trackState<T>() before use:

 session.trackState<GameState>();
 session.trackState<MatchState>();

Definition at line 61 of file Session.ixx.

Private Member Typedefs

Handle_type

using helios::engine::runtime::world::Session::Handle_type = GameObject::Handle_type

Definition at line 63 of file Session.ixx.

63 using Handle_type = GameObject::Handle_type;

Public Constructors

Session()

helios::engine::runtime::world::Session::Session (const GameObject go)
inline explicit

Constructs a session with the given GameObject.

Automatically adds ActiveViewportHandlesStateComponent. State types must be registered separately via trackState<T>().

Parameters
go

The GameObject to use as the session entity.

Definition at line 85 of file Session.ixx.

85 explicit Session(const GameObject go) : gameObject_(go) {
87 gameObject_.add<Uninitialized<Handle_type>>();
88 }

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

Public Member Functions

clearViewportHandles()

void helios::engine::runtime::world::Session::clearViewportHandles ()
inline noexcept

Clears all active viewport handles.

Definition at line 232 of file Session.ixx.

233 gameObject_.get<ActiveViewportHandlesStateComponent<Handle_type>>()->clear();
234 }

destroy()

void helios::engine::runtime::world::Session::destroy ()
inline noexcept

Definition at line 102 of file Session.ixx.

103 gameObject_.add<Destroyed<Handle_type>>();
104 }

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

initialize()

bool helios::engine::runtime::world::Session::initialize ()
inline noexcept

Definition at line 94 of file Session.ixx.

95 return gameObject_.remove<Uninitialized<Handle_type>>();
96 }

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

isActiveViewport()

bool helios::engine::runtime::world::Session::isActiveViewport (const ViewportHandle viewportHandle)
inline noexcept

Returns true if the specified ViewportHandle is currently active.

Parameters
viewportHandle

The ViewportHandle to check for activity.

Returns

true if the ViewportHandle is considered active, otherwise false.

Definition at line 225 of file Session.ixx.

225 [[nodiscard]] bool isActiveViewport(const ViewportHandle viewportHandle) const noexcept {
226 return gameObject_.get<ActiveViewportHandlesStateComponent<Handle_type>>()->has(viewportHandle);
227 }

isDestroyed()

bool helios::engine::runtime::world::Session::isDestroyed ()
inline noexcept

Definition at line 98 of file Session.ixx.

99 return gameObject_.has<Destroyed<Handle_type>>();
100 }

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

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

isInitialized()

bool helios::engine::runtime::world::Session::isInitialized ()
inline noexcept

Definition at line 90 of file Session.ixx.

91 return !gameObject_.has<Uninitialized<Handle_type>>();
92 }

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

playerEntityHandle()

Handle_type helios::engine::runtime::world::Session::playerEntityHandle ()
inline noexcept

Returns the player entity handle.

Returns

The player's entity handle.

Definition at line 120 of file Session.ixx.

121 return playerEntity_;
122 }

reset()

void helios::engine::runtime::world::Session::reset ()
inline

Resets the session state.

Definition at line 127 of file Session.ixx.

127 void reset() {
128
129 }

Referenced by helios::engine::runtime::world::GameWorld::reset.

setPlayerEntityHandle()

void helios::engine::runtime::world::Session::setPlayerEntityHandle (const Handle_type go)
inline noexcept

Sets the player entity handle.

Parameters
go

The player's entity handle.

Definition at line 111 of file Session.ixx.

111 void setPlayerEntityHandle(const Handle_type go) noexcept {
112 playerEntity_ = go;
113 }

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

setStateFrom()

template <typename StateType>
void helios::engine::runtime::world::Session::setStateFrom (const StateTransitionContext< StateType > stateTransitionContext)
inline noexcept

Updates state from a transition context.

Called by StateManager after a successful transition.

Template Parameters
StateType

The state enum type.

Parameters
stateTransitionContext

The completed transition context.

Definition at line 141 of file Session.ixx.

142
143 if (auto* msc = gameObject_.get<StateComponent<StateType>>()) {
144 msc->setStateFromTransitionContext(stateTransitionContext);
145 }
146 }

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

setViewportHandles()

void helios::engine::runtime::world::Session::setViewportHandles (std::span< const ViewportHandle > & viewportHandles)
inline noexcept

Replaces the active viewport IDs with the provided list.

Parameters
viewportHandles

The new list of active viewport IDs.

Definition at line 205 of file Session.ixx.

205 void setViewportHandles(std::span<const ViewportHandle>& viewportHandles) noexcept {
207 }

References setViewportHandles and viewportHandles.

Referenced by setViewportHandles.

state()

template <typename StateType>
StateType helios::engine::runtime::world::Session::state ()
inline noexcept

Returns the current state for a given state type.

Template Parameters
StateType

The state enum type.

Returns

The current state, or StateType::Undefined if not found.

Definition at line 156 of file Session.ixx.

156 [[nodiscard]] StateType state() const noexcept {
157 auto* sc = gameObject_.get<StateComponent<StateType>>();
158
159 return sc ? sc->state() : StateType::Undefined;
160 }

References helios::engine::runtime::registerComponents and helios::engine::state::components::StateComponent< StateType >::state.

stateFrom()

template <typename StateType>
StateType helios::engine::runtime::world::Session::stateFrom ()
inline noexcept

Returns the source state of the last transition.

Template Parameters
StateType

The state enum type.

Returns

The state that was transitioned from, or StateType::Undefined if not found.

Definition at line 170 of file Session.ixx.

171 auto* sc = gameObject_.get<StateComponent<StateType>>();
172
173 return sc ? sc->from() : StateType::Undefined;
174 }

References helios::engine::state::components::StateComponent< StateType >::from and helios::engine::runtime::registerComponents.

stateTransitionId()

template <typename StateType>
StateTransitionIdType< StateType > helios::engine::runtime::world::Session::stateTransitionId ()
inline noexcept

Returns the last transition ID for a given state type.

Template Parameters
StateType

The state enum type.

Returns

The transition ID, or Undefined if not found.

Definition at line 184 of file Session.ixx.

References helios::engine::runtime::registerComponents and helios::engine::state::components::StateComponent< StateType >::transitionId.

trackState()

template <typename StateType>
void helios::engine::runtime::world::Session::trackState ()
inline

Lets this session track the specified StateType.

Template Parameters
StateType

The state enum type.

Definition at line 196 of file Session.ixx.

196 void trackState() {
197 gameObject_.getOrAdd<StateComponent<StateType>>();
198 }

viewportHandles()

std::span< const ViewportHandle > helios::engine::runtime::world::Session::viewportHandles ()
inline noexcept

Returns the currently active viewport handles.

Returns

Read-only span of viewport handles.

Definition at line 214 of file Session.ixx.

214 [[nodiscard]] std::span<const ViewportHandle> viewportHandles() const noexcept {
216 }

Reference viewportHandles.

Referenced by setViewportHandles and viewportHandles.

Private Member Attributes

gameObject_

GameObject helios::engine::runtime::world::Session::gameObject_

The underlying GameObject storing session components.

Definition at line 68 of file Session.ixx.

68 GameObject gameObject_;

playerEntity_

Handle_type helios::engine::runtime::world::Session::playerEntity_

Handle to the player entity.

Definition at line 73 of file Session.ixx.

73 Handle_type playerEntity_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.