UpdateContext Class
Per-frame context passed to systems during game loop updates. More...
Declaration
Public Constructors Index
| UpdateContext (helios::engine::runtime::world::ResourceRegistry &resourceRegistry, helios::engine::ecs::EntityResolver entityResolver, helios::engine::runtime::world::Session &session, const float deltaTime, const float totalTime, helios::engine::runtime::messaging::event::GameLoopEventBus &phaseEventBus, helios::engine::runtime::messaging::event::GameLoopEventBus &passEventBus, helios::engine::runtime::messaging::event::GameLoopEventBus &frameEventBus, const helios::input::InputSnapshot &inputSnapshot, std::span< const helios::rendering::ViewportSnapshot > viewportSnapshots, const Level *level) | |
|
Constructs an UpdateContext with all per-frame dependencies. More... | |
Public Member Functions Index
| std::span< const helios::rendering::ViewportSnapshot > | viewportSnapshots () const noexcept |
|
Returns the viewport snapshots for this frame. More... | |
| float | deltaTime () const noexcept |
|
Returns the time elapsed since the last frame, in seconds. More... | |
| float | totalTime () const noexcept |
|
Returns the time elapsed since the first frame, in seconds. More... | |
| const helios::input::InputSnapshot & | inputSnapshot () const noexcept |
|
Returns the immutable input snapshot for this frame. More... | |
| std::optional< helios::engine::ecs::GameObject > | find (helios::engine::ecs::EntityHandle handle) const noexcept |
|
Resolves an EntityHandle to a GameObject. More... | |
| helios::engine::ecs::EntityResolver & | entityResolver () noexcept |
|
Returns the EntityResolver for direct handle validation. More... | |
| const Level * | level () noexcept |
template <typename T, typename ... Args> | |
| void | queueCommand (Args &&...args) const noexcept |
|
Submits a command to the EngineCommandBuffer. More... | |
| helios::engine::runtime::world::Session & | session () const noexcept |
|
Returns the session for game/match state access. More... | |
template <typename E, typename... Args> | |
| void | pushPass (Args &&... args) |
|
Pushes an event to the pass-level event bus. More... | |
template <typename E, typename... Args> | |
| void | pushPhase (Args &&... args) |
|
Pushes an event to the phase-level event bus. More... | |
template <typename E> | |
| auto | readPhase () -> std::span< const E > |
|
Reads events from the phase-level event bus. More... | |
template <typename E> | |
| auto | readPass () -> std::span< const E > |
|
Reads events from the pass-level event bus. More... | |
template <typename E> | |
| auto | readFrame () -> std::span< const E > |
|
Reads events from the frame-level event bus. More... | |
template <typename E, typename... Args> | |
| void | pushFrame (Args &&... args) |
|
Pushes an event to the frame-level event bus. More... | |
template <typename... Components> | |
| auto | view () |
|
Creates a View for querying entities with the given component types. More... | |
template <typename... Components> | |
| auto | view () const |
|
Creates a View for querying entities with the given component types. More... | |
Private Member Attributes Index
| float | deltaTime_ = 0.0f |
|
Time elapsed since the last frame, in seconds. More... | |
| float | totalTime_ = 0.0f |
|
Time elapsed since the first frame, in seconds. More... | |
| const helios::input::InputSnapshot & | inputSnapshot_ |
|
Immutable snapshot of input state for the current frame. More... | |
| helios::engine::runtime::world::Session & | session_ |
|
Reference to the current game session for state tracking. More... | |
| helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink | phaseEventSink_ |
|
Sink for pushing phase-level events during update. More... | |
| const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource | phaseEventSource_ |
|
Source for reading phase-level events from the previous phase. More... | |
| helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink | passEventSink_ |
|
Sink for pushing pass-level events during update. More... | |
| const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource | passEventSource_ |
|
Source for reading pass-level events from previous passes. More... | |
| helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink | frameEventSink_ |
|
Sink for pushing frame-level events during update. More... | |
| const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource | frameEventSource_ |
|
Source for reading frame-level events from the previous frame. More... | |
| std::span< const helios::rendering::ViewportSnapshot > | viewportSnapshots_ |
|
Immutable snapshot of all viewport states for this frame. More... | |
| helios::engine::runtime::world::ResourceRegistry & | resourceRegistry_ |
|
Reference to the ResourceRegistry for O(1) resource lookup. More... | |
| helios::engine::ecs::EntityResolver | entityResolver_ |
|
Callable for resolving EntityHandles to GameObjects. More... | |
| const Level * | level_ |
|
Pointer to the active Level, or nullptr if no level is loaded. More... | |
Description
Per-frame context passed to systems during game loop updates.
UpdateContext bundles all state that systems need for a single frame update: timing, input, resource access, entity resolution, event buses, and the active level. It is constructed by the GameLoop each frame and passed to every System::update() call.
## Resource Access
- `queueCommand<T>(args...)` — submits a command to the EngineCommandBuffer
- `session()` — cross-frame state (tracked game/match states)
- `level()` — current Level with arena bounds
## Entity Access
- `find(handle)` — resolves an EntityHandle to a GameObject (validates the handle's version via the EntityResolver)
- `entityResolver()` — direct access to the callable resolver
## Event Propagation
| Level | Push | Read | Scope | |-------|------|------|-------| | Pass | `pushPass()` | `readPass()` | Within same phase, after commit point | | Phase | `pushPhase()` | `readPhase()` | Across phases within same frame | | Frame | `pushFrame()` | `readFrame()` | Across frames |
- See Also
GameLoop
- See Also
- See Also
- See Also
- See Also
EntityResolver
- See Also
InputSnapshot
Definition at line 72 of file UpdateContext.ixx.
Public Constructors
UpdateContext()
| inline |
Constructs an UpdateContext with all per-frame dependencies.
- Parameters
-
resourceRegistry Reference to the ResourceRegistry for resource lookup.
entityResolver Callable for resolving EntityHandles to GameObjects.
session Reference to the current game session.
deltaTime Time since last frame in seconds.
totalTime Accumulated time since the first frame in seconds.
phaseEventBus Reference to the phase-level event bus.
passEventBus Reference to the pass-level event bus.
frameEventBus Reference to the frame-level event bus.
inputSnapshot Immutable input state for this frame.
viewportSnapshots Immutable snapshot of viewport states.
level Pointer to the active Level, or nullptr.
Definition at line 173 of file UpdateContext.ixx.
References deltaTime, entityResolver, inputSnapshot, level, session, totalTime and viewportSnapshots.
Public Member Functions
deltaTime()
| inline nodiscard noexcept |
Returns the time elapsed since the last frame, in seconds.
- Returns
Delta time in seconds.
Definition at line 219 of file UpdateContext.ixx.
Referenced by UpdateContext.
entityResolver()
| inline nodiscard noexcept |
Returns the EntityResolver for direct handle validation.
- Returns
Reference to the EntityResolver.
Definition at line 261 of file UpdateContext.ixx.
Referenced by UpdateContext.
find()
| inline nodiscard noexcept |
Resolves an EntityHandle to a GameObject.
Validates the handle via the EntityResolver and returns a lightweight GameObject wrapper if the entity is still alive.
- Parameters
-
handle The entity handle to resolve.
- Returns
A GameObject if the handle is valid, std::nullopt otherwise.
Definition at line 251 of file UpdateContext.ixx.
Referenced by helios::engine::modules::ui::widgets::systems::MenuDisplaySystem< StateLft, StateRgt >::focusMenu, helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::hasLifeLeft, helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::isPlayerActive, helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::isPlayerInactive and helios::engine::modules::ui::widgets::systems::MenuNavigationSystem::update.
inputSnapshot()
| inline nodiscard noexcept |
Returns the immutable input snapshot for this frame.
- Returns
Const ref to the current InputSnapshot.
Definition at line 237 of file UpdateContext.ixx.
Referenced by helios::engine::modules::ui::widgets::systems::MenuNavigationSystem::update and UpdateContext.
level()
| inline nodiscard noexcept |
Returns the active Level.
- Returns
Pointer to the Level, or nullptr if no level is loaded.
Definition at line 270 of file UpdateContext.ixx.
Referenced by UpdateContext.
pushFrame()
| inline |
Pushes an event to the frame-level event bus.
Events pushed here become readable in the next frame via `readFrame()`. The frame event bus is swapped at the end of the Post phase in GameLoop.
Use frame-level events for cross-frame communication where events should persist beyond the current phase.
- Template Parameters
-
E The event type to push.
Args Constructor argument types for the event.
- Parameters
-
args Arguments forwarded to the event constructor.
- See Also
- See Also
GameLoop
Definition at line 420 of file UpdateContext.ixx.
pushPass()
| inline |
Pushes an event to the pass-level event bus.
Events pushed here become readable in subsequent passes within the same phase, after a commit point is reached.
- Template Parameters
-
E The event type to push.
Args Constructor argument types for the event.
- Parameters
-
args Arguments forwarded to the event constructor.
- See Also
- See Also
Pass::addCommitPoint()
Definition at line 316 of file UpdateContext.ixx.
pushPhase()
| inline |
Pushes an event to the phase-level event bus.
Events pushed here become readable in subsequent phases, after the current phase commits.
- Template Parameters
-
E The event type to push.
Args Constructor argument types for the event.
- Parameters
-
args Arguments forwarded to the event constructor.
- See Also
- See Also
GameLoop
Definition at line 335 of file UpdateContext.ixx.
queueCommand()
| inline noexcept |
Submits a command to the EngineCommandBuffer.
Constructs and enqueues a command of type T. The command will be executed during the next commit point (phase or pass boundary).
- Template Parameters
-
T The command type to submit.
Args Constructor argument types for T.
- Parameters
-
args Arguments forwarded to the command constructor.
Definition at line 287 of file UpdateContext.ixx.
Referenced by helios::engine::modules::ui::widgets::systems::MenuNavigationSystem::update.
readFrame()
| inline |
Reads events from the frame-level event bus.
Returns events that were pushed during the previous frame via `pushFrame()`. The frame event bus is swapped at the end of the Post phase, making events readable in the subsequent frame.
Frame-level events are useful for cross-frame communication, such as:
- Collision events that trigger effects in the next frame
- Spawn confirmations for UI updates
- Audio/VFX triggers
- Template Parameters
-
E The event type to read.
- Returns
A span of const events of type E.
- See Also
- See Also
GameLoop
Definition at line 397 of file UpdateContext.ixx.
readPass()
| inline |
Reads events from the pass-level event bus.
Returns events that were pushed during previous passes within the current phase via `pushPass()`. The pass event bus is swapped at commit points, configured via Pass::addCommitPoint().
- Template Parameters
-
E The event type to read.
- Returns
A span of const events of type E.
- See Also
- See Also
Pass::addCommitPoint()
Definition at line 373 of file UpdateContext.ixx.
readPhase()
| inline |
Reads events from the phase-level event bus.
Returns events that were pushed during the previous phase via `pushPhase()`. The phase event bus is swapped at phase boundaries, configured in GameLoop::phaseCommit().
- Template Parameters
-
E The event type to read.
- Returns
A span of const events of type E.
- See Also
- See Also
GameLoop
Definition at line 354 of file UpdateContext.ixx.
session()
| inline nodiscard noexcept |
Returns the session for game/match state access.
- Returns
Ref to the Session used with this UpdateContext.
Definition at line 296 of file UpdateContext.ixx.
Referenced by helios::engine::state::StateManager< types::GameState >::flush, helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::hasLifeLeft, helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::isPlayerActive, helios::engine::mechanics::match::rules::guards::DefaultMatchStateTransitionGuards::isPlayerInactive, helios::engine::runtime::gameloop::TypedPass< StateType >::shouldRun and UpdateContext.
totalTime()
| inline nodiscard noexcept |
Returns the time elapsed since the first frame, in seconds.
- Returns
Total time in seconds.
Definition at line 228 of file UpdateContext.ixx.
Referenced by UpdateContext.
view()
| inline nodiscard |
Creates a View for querying entities with the given component types.
Convenience shortcut that avoids accessing the GameWorld directly. Delegates to the EntityManager owned by the EntityResolver.
- Template Parameters
-
Components The component types to query.
- Returns
A View over all entities possessing every requested component.
- See Also
Definition at line 439 of file UpdateContext.ixx.
Referenced by helios::engine::ecs::systems::HierarchyPropagationSystem::update, helios::engine::modules::physics::collision::systems::GridCollisionDetectionSystem::update and helios::engine::modules::ui::widgets::systems::MenuNavigationSystem::update.
view()
| inline nodiscard |
Creates a View for querying entities with the given component types.
Convenience shortcut that avoids accessing the GameWorld directly. Delegates to the EntityManager owned by the EntityResolver.
- Template Parameters
-
Components The component types to query.
- Returns
A View over all entities possessing every requested component.
- See Also
Definition at line 447 of file UpdateContext.ixx.
viewportSnapshots()
| inline nodiscard noexcept |
Returns the viewport snapshots for this frame.
- Returns
A span of const ViewportSnapshot objects.
Definition at line 209 of file UpdateContext.ixx.
Referenced by UpdateContext.
Private Member Attributes
deltaTime_
|
Time elapsed since the last frame, in seconds.
Definition at line 78 of file UpdateContext.ixx.
entityResolver_
|
Callable for resolving EntityHandles to GameObjects.
Definition at line 148 of file UpdateContext.ixx.
frameEventSink_
|
Sink for pushing frame-level events during update.
Used by systems and components to publish events that will be processed in the next frame. Frame-level events persist across all phases and are swapped at the end of the Post phase.
Definition at line 128 of file UpdateContext.ixx.
frameEventSource_
|
Source for reading frame-level events from the previous frame.
Definition at line 133 of file UpdateContext.ixx.
inputSnapshot_
|
Immutable snapshot of input state for the current frame.
Definition at line 88 of file UpdateContext.ixx.
level_
|
Pointer to the active Level, or nullptr if no level is loaded.
Definition at line 153 of file UpdateContext.ixx.
passEventSink_
|
Sink for pushing pass-level events during update.
Used by systems and components to publish events that will be processed in subsequent passes within the same phase, after a commit point.
Definition at line 114 of file UpdateContext.ixx.
passEventSource_
|
Source for reading pass-level events from previous passes.
Definition at line 119 of file UpdateContext.ixx.
phaseEventSink_
|
Sink for pushing phase-level events during update.
Used by systems and components to publish events (e.g., collision, spawn requests) that will be processed in the next phase of the game loop.
Definition at line 101 of file UpdateContext.ixx.
phaseEventSource_
|
Source for reading phase-level events from the previous phase.
Definition at line 106 of file UpdateContext.ixx.
resourceRegistry_
|
Reference to the ResourceRegistry for O(1) resource lookup.
Definition at line 143 of file UpdateContext.ixx.
session_
|
Reference to the current game session for state tracking.
Definition at line 93 of file UpdateContext.ixx.
totalTime_
|
Time elapsed since the first frame, in seconds.
Definition at line 83 of file UpdateContext.ixx.
viewportSnapshots_
|
Immutable snapshot of all viewport states for this frame.
Definition at line 138 of file UpdateContext.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.