Skip to main content

Session Class

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

Declaration

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

Public Constructors Index

Session (const ecs::GameObject go)

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

Public Member Functions Index

voidsetPlayerEntityHandle (const ecs::EntityHandle go) noexcept

Sets the player entity handle. More...

ecs::EntityHandleplayerEntityHandle () 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...

voidsetViewportIds (std::span< const helios::engine::common::types::ViewportId > &viewportIds) noexcept

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

std::span< const helios::engine::common::types::ViewportId >viewportIds () const noexcept

Returns the currently active viewport IDs. More...

voidclearViewportIds () noexcept

Clears all active viewport IDs. More...

Private Member Attributes Index

ecs::GameObjectgameObject_

The underlying GameObject storing session components. More...

ecs::EntityHandleplayerEntity_

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:

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

## Stored Components

  • `StateComponent<T>` - Registered via trackState<T>()
  • `ActiveViewportIdsStateComponent` - Active viewport list (auto-added)
See Also

StateComponent

See Also

StateManager

Definition at line 62 of file Session.ixx.

Public Constructors

Session()

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

Constructs a session with the given GameObject.

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

Parameters
go

The GameObject to use as the session entity.

Definition at line 84 of file Session.ixx.

84 explicit Session(const ecs::GameObject go) : gameObject_(go) {
85 gameObject_.add<ActiveViewportIdsStateComponent>();
86 }

Public Member Functions

clearViewportIds()

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

Clears all active viewport IDs.

Definition at line 203 of file Session.ixx.

203 void clearViewportIds() noexcept {
204 gameObject_.get<ActiveViewportIdsStateComponent>()->clear();
205 }

playerEntityHandle()

ecs::EntityHandle helios::engine::runtime::world::Session::playerEntityHandle ()
inline nodiscard noexcept

reset()

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

Resets the session state.

Definition at line 109 of file Session.ixx.

109 void reset() {
110
111 }

setPlayerEntityHandle()

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

Sets the player entity handle.

Parameters
go

The player's entity handle.

Definition at line 93 of file Session.ixx.

93 void setPlayerEntityHandle(const ecs::EntityHandle go) noexcept {
94 playerEntity_ = go;
95 }

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 123 of file Session.ixx.

123 void setStateFrom(const StateTransitionContext<StateType> stateTransitionContext) noexcept {
124
125 if (auto* msc = gameObject_.get<StateComponent<StateType>>()) {
126 msc->setStateFromTransitionContext(stateTransitionContext);
127 }
128 }

setViewportIds()

void helios::engine::runtime::world::Session::setViewportIds (std::span< const helios::engine::common::types::ViewportId > & viewportIds)
inline noexcept

Replaces the active viewport IDs with the provided list.

Parameters
viewportIds

The new list of active viewport IDs.

Definition at line 187 of file Session.ixx.

187 void setViewportIds(std::span<const helios::engine::common::types::ViewportId>& viewportIds) noexcept {
189 }

References setViewportIds and viewportIds.

Referenced by setViewportIds.

state()

template <typename StateType>
StateType helios::engine::runtime::world::Session::state ()
inline nodiscard 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 138 of file Session.ixx.

138 [[nodiscard]] StateType state() const noexcept {
139 auto* sc = gameObject_.get<StateComponent<StateType>>();
140
141 return sc ? sc->state() : StateType::Undefined;
142 }

Reference helios::engine::state::components::StateComponent< StateType >::state.

Referenced by helios::engine::state::StateManager< types::GameState >::flush and helios::engine::runtime::gameloop::TypedPass< StateType >::shouldRun.

stateFrom()

template <typename StateType>
StateType helios::engine::runtime::world::Session::stateFrom ()
inline nodiscard 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 152 of file Session.ixx.

152 [[nodiscard]] StateType stateFrom() const noexcept {
153 auto* sc = gameObject_.get<StateComponent<StateType>>();
154
155 return sc ? sc->from() : StateType::Undefined;
156 }

Reference helios::engine::state::components::StateComponent< StateType >::from.

stateTransitionId()

template <typename StateType>
StateTransitionIdType< StateType > helios::engine::runtime::world::Session::stateTransitionId ()
inline nodiscard 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 166 of file Session.ixx.

166 [[nodiscard]] StateTransitionIdType<StateType> stateTransitionId() const noexcept {
167 auto* ms = gameObject_.get<StateComponent<StateType>>();
168
170 }

Reference 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 178 of file Session.ixx.

178 void trackState() {
179 gameObject_.getOrAdd<StateComponent<StateType>>();
180 }

viewportIds()

std::span< const helios::engine::common::types::ViewportId > helios::engine::runtime::world::Session::viewportIds ()
inline nodiscard noexcept

Returns the currently active viewport IDs.

Returns

Read-only span of viewport identifiers.

Definition at line 196 of file Session.ixx.

196 [[nodiscard]] std::span<const helios::engine::common::types::ViewportId> viewportIds() const noexcept {
197 return gameObject_.get<ActiveViewportIdsStateComponent>()->viewportIds();
198 }

Reference viewportIds.

Referenced by setViewportIds and viewportIds.

Private Member Attributes

gameObject_

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

The underlying GameObject storing session components.

Definition at line 67 of file Session.ixx.

67 ecs::GameObject gameObject_;

playerEntity_

ecs::EntityHandle helios::engine::runtime::world::Session::playerEntity_

Handle to the player entity.

Definition at line 72 of file Session.ixx.

72 ecs::EntityHandle playerEntity_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.