Skip to main content

UpdateContext Class

Per-frame context passed to systems during game loop updates. More...

Declaration

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

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...

floatdeltaTime () const noexcept

Returns the time elapsed since the last frame, in seconds. More...

floattotalTime () 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

Returns the active Level. More...

template <typename T, typename ... Args>
voidqueueCommand (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>
voidpushPass (Args &&... args)

Pushes an event to the pass-level event bus. More...

template <typename E, typename... Args>
voidpushPhase (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>
voidpushFrame (Args &&... args)

Pushes an event to the frame-level event bus. More...

template <typename... Components>
autoview ()

Creates a View for querying entities with the given component types. More...

template <typename... Components>
autoview () const

Creates a View for querying entities with the given component types. More...

Private Member Attributes Index

floatdeltaTime_ = 0.0f

Time elapsed since the last frame, in seconds. More...

floattotalTime_ = 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::WriteSinkphaseEventSink_

Sink for pushing phase-level events during update. More...

const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSourcephaseEventSource_

Source for reading phase-level events from the previous phase. More...

helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSinkpassEventSink_

Sink for pushing pass-level events during update. More...

const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSourcepassEventSource_

Source for reading pass-level events from previous passes. More...

helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSinkframeEventSink_

Sink for pushing frame-level events during update. More...

const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSourceframeEventSource_

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::EntityResolverentityResolver_

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

ResourceRegistry

See Also

EngineCommandBuffer

See Also

Session

See Also

EntityResolver

See Also

InputSnapshot

Definition at line 72 of file UpdateContext.ixx.

Public Constructors

UpdateContext()

helios::engine::runtime::world::UpdateContext::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)
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.

177 const float deltaTime,
178 const float totalTime,
183 std::span<const helios::rendering::ViewportSnapshot> viewportSnapshots,
184 const Level* level
185 ) :
186 resourceRegistry_(resourceRegistry),
187 entityResolver_(entityResolver),
188 session_(session),
189 deltaTime_(deltaTime),
190 totalTime_(totalTime),
191 phaseEventSink_(phaseEventBus.writeSink()),
192 phaseEventSource_(phaseEventBus.readSource()),
193 passEventSink_(passEventBus.writeSink()),
194 passEventSource_(passEventBus.readSource()),
195 frameEventSink_(frameEventBus.writeSink()),
196 frameEventSource_(frameEventBus.readSource()),
197 inputSnapshot_(inputSnapshot),
198 viewportSnapshots_(viewportSnapshots),
199 level_(level)
200 {
201
202 }

References deltaTime, entityResolver, inputSnapshot, level, session, totalTime and viewportSnapshots.

Public Member Functions

deltaTime()

float helios::engine::runtime::world::UpdateContext::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.

219 [[nodiscard]] float deltaTime() const noexcept {
220 return deltaTime_;
221 }

Referenced by UpdateContext.

entityResolver()

helios::engine::ecs::EntityResolver & helios::engine::runtime::world::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.

262 return entityResolver_;
263 }

Referenced by UpdateContext.

find()

std::optional< helios::engine::ecs::GameObject > helios::engine::runtime::world::UpdateContext::find (helios::engine::ecs::EntityHandle handle)
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.

251 [[nodiscard]] std::optional<helios::engine::ecs::GameObject> find(helios::engine::ecs::EntityHandle handle) const noexcept {
252 return entityResolver_(handle);
253 }

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()

const helios::input::InputSnapshot & helios::engine::runtime::world::UpdateContext::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.

237 [[nodiscard]] const helios::input::InputSnapshot& inputSnapshot() const noexcept {
238 return inputSnapshot_;
239 }

Referenced by helios::engine::modules::ui::widgets::systems::MenuNavigationSystem::update and UpdateContext.

level()

const Level * helios::engine::runtime::world::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.

270 [[nodiscard]] const Level* level() noexcept {
271 return level_;
272 }

Referenced by UpdateContext.

pushFrame()

template <typename E, typename... Args>
void helios::engine::runtime::world::UpdateContext::pushFrame (Args &&... args)
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

readFrame()

See Also

GameLoop

Definition at line 420 of file UpdateContext.ixx.

420 void pushFrame(Args&&... args) {
421 frameEventSink_.template push<E>(std::forward<Args>(args)...);
422 }

pushPass()

template <typename E, typename... Args>
void helios::engine::runtime::world::UpdateContext::pushPass (Args &&... args)
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

readPass()

See Also

Pass::addCommitPoint()

Definition at line 316 of file UpdateContext.ixx.

316 void pushPass(Args&&... args) {
317 passEventSink_.template push<E>(std::forward<Args>(args)...);
318 }

pushPhase()

template <typename E, typename... Args>
void helios::engine::runtime::world::UpdateContext::pushPhase (Args &&... args)
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

readPhase()

See Also

GameLoop

Definition at line 335 of file UpdateContext.ixx.

335 void pushPhase(Args&&... args) {
336 phaseEventSink_.template push<E>(std::forward<Args>(args)...);
337 }

queueCommand()

template <typename T, typename ... Args>
void helios::engine::runtime::world::UpdateContext::queueCommand (Args &&... args)
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.

287 void queueCommand(Args&&...args) const noexcept {
288 resourceRegistry_.tryGet<EngineCommandBuffer>()->add<T>(std::forward<Args>(args)...);
289 }

Referenced by helios::engine::modules::ui::widgets::systems::MenuNavigationSystem::update.

readFrame()

template <typename E>
std::span< const E > helios::engine::runtime::world::UpdateContext::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

pushFrame()

See Also

GameLoop

Definition at line 397 of file UpdateContext.ixx.

397 std::span<const E> readFrame() {
398 return frameEventSource_.template read<E>();
399 }

readPass()

template <typename E>
std::span< const E > helios::engine::runtime::world::UpdateContext::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

pushPass()

See Also

Pass::addCommitPoint()

Definition at line 373 of file UpdateContext.ixx.

373 std::span<const E> readPass() {
374 return passEventSource_.template read<E>();
375 }

readPhase()

template <typename E>
std::span< const E > helios::engine::runtime::world::UpdateContext::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

pushPhase()

See Also

GameLoop

Definition at line 354 of file UpdateContext.ixx.

354 std::span<const E> readPhase() {
355 return phaseEventSource_.template read<E>();
356 }

session()

totalTime()

float helios::engine::runtime::world::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.

228 [[nodiscard]] float totalTime() const noexcept {
229 return totalTime_;
230 }

Referenced by UpdateContext.

view()

template <typename... Components>
auto helios::engine::runtime::world::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

helios::engine::ecs::View

Definition at line 439 of file UpdateContext.ixx.

439 [[nodiscard]] auto view() {
440 return helios::engine::ecs::View<Components...>(entityResolver_.em);
441 }

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()

template <typename... Components>
auto helios::engine::runtime::world::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

helios::engine::ecs::View

Definition at line 447 of file UpdateContext.ixx.

447 [[nodiscard]] auto view() const {
448 return helios::engine::ecs::View<const Components...>(entityResolver_.em);
449 }

viewportSnapshots()

std::span< const helios::rendering::ViewportSnapshot > helios::engine::runtime::world::UpdateContext::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.

209 [[nodiscard]] std::span<const helios::rendering::ViewportSnapshot> viewportSnapshots() const noexcept {
210 return viewportSnapshots_;
211 }

Referenced by UpdateContext.

Private Member Attributes

deltaTime_

float helios::engine::runtime::world::UpdateContext::deltaTime_ = 0.0f

Time elapsed since the last frame, in seconds.

Definition at line 78 of file UpdateContext.ixx.

78 float deltaTime_ = 0.0f;

entityResolver_

helios::engine::ecs::EntityResolver helios::engine::runtime::world::UpdateContext::entityResolver_

Callable for resolving EntityHandles to GameObjects.

Definition at line 148 of file UpdateContext.ixx.

frameEventSink_

helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink helios::engine::runtime::world::UpdateContext::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.

128 helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink frameEventSink_;

frameEventSource_

const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource helios::engine::runtime::world::UpdateContext::frameEventSource_

Source for reading frame-level events from the previous frame.

Definition at line 133 of file UpdateContext.ixx.

133 const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource frameEventSource_;

inputSnapshot_

const helios::input::InputSnapshot& helios::engine::runtime::world::UpdateContext::inputSnapshot_

Immutable snapshot of input state for the current frame.

Definition at line 88 of file UpdateContext.ixx.

88 const helios::input::InputSnapshot& inputSnapshot_;

level_

const Level* helios::engine::runtime::world::UpdateContext::level_

Pointer to the active Level, or nullptr if no level is loaded.

Definition at line 153 of file UpdateContext.ixx.

153 const Level* level_;

passEventSink_

helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink helios::engine::runtime::world::UpdateContext::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.

114 helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink passEventSink_;

passEventSource_

const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource helios::engine::runtime::world::UpdateContext::passEventSource_

Source for reading pass-level events from previous passes.

Definition at line 119 of file UpdateContext.ixx.

119 const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource passEventSource_;

phaseEventSink_

helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink helios::engine::runtime::world::UpdateContext::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.

101 helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink phaseEventSink_;

phaseEventSource_

const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource helios::engine::runtime::world::UpdateContext::phaseEventSource_

Source for reading phase-level events from the previous phase.

Definition at line 106 of file UpdateContext.ixx.

106 const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource phaseEventSource_;

resourceRegistry_

helios::engine::runtime::world::ResourceRegistry& helios::engine::runtime::world::UpdateContext::resourceRegistry_

Reference to the ResourceRegistry for O(1) resource lookup.

Definition at line 143 of file UpdateContext.ixx.

session_

helios::engine::runtime::world::Session& helios::engine::runtime::world::UpdateContext::session_

Reference to the current game session for state tracking.

Definition at line 93 of file UpdateContext.ixx.

totalTime_

float helios::engine::runtime::world::UpdateContext::totalTime_ = 0.0f

Time elapsed since the first frame, in seconds.

Definition at line 83 of file UpdateContext.ixx.

83 float totalTime_ = 0.0f;

viewportSnapshots_

std::span<const helios::rendering::ViewportSnapshot> helios::engine::runtime::world::UpdateContext::viewportSnapshots_

Immutable snapshot of all viewport states for this frame.

Definition at line 138 of file UpdateContext.ixx.

138 std::span<const helios::rendering::ViewportSnapshot> viewportSnapshots_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.