Session.ixx File
Session state container for game-wide state. More...
Included Headers
#include <optional>
#include <vector>
#include <span>
#include <cassert>
#include <helios.engine.rendering.viewport.components.ActiveViewportHandlesStateComponent>
#include <helios.engine.rendering.viewport.types.ViewportHandle>
#include <helios.ecs.types.EntityHandle>
#include <helios.engine.runtime.world.GameObject>
#include <helios.engine.runtime.enginestate.EngineStateBindings>
#include <helios.engine.state.types.StateTransitionId>
#include <helios.engine.state.components>
#include <helios.engine.state.types.StateTransitionContext>
#include <helios.ecs.components>
Namespaces Index
| namespace | helios |
| namespace | engine |
| namespace | runtime |
| namespace | world |
Classes Index
| class | Session |
|
Holds session-level state for the current game instance. More... | |
Description
Session state container for game-wide state.
File Listing
The file content with the documentation metadata removed is:
29using namespace helios::engine::state::components;
31using namespace helios::engine::rendering::viewport::components;
33using namespace helios::engine::state::types;
34using namespace helios::engine::rendering::viewport::types;
35using namespace helios::engine::runtime::world;
37export namespace helios::engine::runtime::world {
68 GameObject gameObject_;
85 explicit Session(const GameObject go) : gameObject_(go) {
86 gameObject_.add<ActiveViewportHandlesStateComponent<Handle_type>>();
87 gameObject_.add<Uninitialized<Handle_type>>();
90 [[nodiscard]] bool isInitialized() const noexcept {
91 return !gameObject_.has<Uninitialized<Handle_type>>();
94 [[nodiscard]] bool initialize() noexcept {
95 return gameObject_.remove<Uninitialized<Handle_type>>();
98 [[nodiscard]] bool isDestroyed() noexcept {
99 return gameObject_.has<Destroyed<Handle_type>>();
103 gameObject_.add<Destroyed<Handle_type>>();
111 void setPlayerEntityHandle(const Handle_type go) noexcept {
112 playerEntity_ = go;
120 [[nodiscard]] Handle_type playerEntityHandle() const noexcept {
141 void setStateFrom(const StateTransitionContext<StateType> stateTransitionContext) noexcept {
143 if (auto* msc = gameObject_.get<StateComponent<StateType>>()) {
144 msc->setStateFromTransitionContext(stateTransitionContext);
157 auto* sc = gameObject_.get<StateComponent<StateType>>();
171 auto* sc = gameObject_.get<StateComponent<StateType>>();
185 auto* ms = gameObject_.get<StateComponent<StateType>>();
187 return ms ? ms->transitionId() : StateTransitionIdType<StateType>::Undefined;
196 void trackState() {
197 gameObject_.getOrAdd<StateComponent<StateType>>();
205 void setViewportHandles(std::span<const ViewportHandle>& viewportHandles) noexcept {
206 gameObject_.get<ActiveViewportHandlesStateComponent<Handle_type>>()->setViewportHandles(viewportHandles);
214 [[nodiscard]] std::span<const ViewportHandle> viewportHandles() const noexcept {
215 return gameObject_.get<ActiveViewportHandlesStateComponent<Handle_type>>()->viewportHandles();
225 [[nodiscard]] bool isActiveViewport(const ViewportHandle viewportHandle) const noexcept {
226 return gameObject_.get<ActiveViewportHandlesStateComponent<Handle_type>>()->has(viewportHandle);
232 void clearViewportHandles() noexcept {
233 gameObject_.get<ActiveViewportHandlesStateComponent<Handle_type>>()->clear();
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.