Skip to main content

UpdateContext Struct

Context passed to Updatable components during per-frame updates. More...

Declaration

struct helios::engine::game::UpdateContext { ... }

Public Constructors Index

UpdateContext (helios::engine::game::CommandBuffer &commandBuffer, helios::engine::game::GameWorld &gameWorld, const helios::engine::game::event::GameLoopEventSink &eventSink)

Constructs an UpdateContext with required dependencies. More...

Public Member Functions Index

floatdeltaTime () const noexcept

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

UpdateContext &setDeltaTime (float dt) noexcept

Sets the time elapsed since the last frame. More...

const helios::engine::game::InputSnapshot &inputSnapshot () const noexcept

Returns the immutable input snapshot for this frame. More...

UpdateContext &setInputSnapshot (const helios::engine::game::InputSnapshot &snapshot) noexcept

Sets the input snapshot for this frame. More...

helios::engine::game::CommandBuffer &commandBuffer () const noexcept

Returns the command buffer for queueing commands. More...

helios::engine::game::GameWorld &gameWorld () const noexcept

Returns the game world for entity lookups. More...

template <typename E, typename... Args>
voidpushEvent (Args &&... args)

Pushes an event to the game loop event bus. More...

Private Member Attributes Index

floatdeltaTime_ = 0.0f

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

const helios::engine::game::InputSnapshot *inputSnapshot_ = nullptr

Immutable snapshot of input state for the current frame. More...

helios::engine::game::CommandBuffer &commandBuffer_

Buffer for queueing commands to be executed at end of frame. More...

helios::engine::game::GameWorld &gameWorld_

Reference to the game world for entity lookups. More...

helios::engine::game::event::GameLoopEventSinkeventSink_

Sink for pushing game loop events during update. More...

Description

Context passed to Updatable components during per-frame updates.

Provides all necessary state for components to perform their update logic, including frame timing, input state, and access to the command system. All pointers are non-owning; the caller is responsible for lifetime management.

Definition at line 28 of file UpdateContext.ixx.

Public Constructors

UpdateContext()

helios::engine::game::UpdateContext::UpdateContext (helios::engine::game::CommandBuffer & commandBuffer, helios::engine::game::GameWorld & gameWorld, const helios::engine::game::event::GameLoopEventSink & eventSink)
inline

Constructs an UpdateContext with required dependencies.

Parameters
commandBuffer

Non-owning pointer to the command buffer. Must not be nullptr.

gameWorld

Non-owning pointer to the game world. Must not be nullptr.

eventSink

Sink for pushing game loop events. Used to publish events during update phases for later processing.

Exceptions
std::invalid_argument

if either commandBuffer or gameWorld are nullptr.

Definition at line 71 of file UpdateContext.ixx.

References commandBuffer and gameWorld.

Referenced by setDeltaTime and setInputSnapshot.

Public Member Functions

commandBuffer()

helios::engine::game::CommandBuffer & helios::engine::game::UpdateContext::commandBuffer ()
inline nodiscard noexcept

Returns the command buffer for queueing commands.

Returns

Ref to the CommandBuffer used with this UpdateContext.

Definition at line 125 of file UpdateContext.ixx.

125 [[nodiscard]] helios::engine::game::CommandBuffer& commandBuffer() const noexcept {
126 return commandBuffer_;
127 }

Referenced by UpdateContext.

deltaTime()

float helios::engine::game::UpdateContext::deltaTime ()
inline nodiscard noexcept

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

Definition at line 80 of file UpdateContext.ixx.

80 [[nodiscard]] float deltaTime() const noexcept {
81 return deltaTime_;
82 }

gameWorld()

helios::engine::game::GameWorld & helios::engine::game::UpdateContext::gameWorld ()
inline nodiscard noexcept

Returns the game world for entity lookups.

Returns

Ref to the GameWorld used with this UpdateContext.

Definition at line 134 of file UpdateContext.ixx.

134 [[nodiscard]] helios::engine::game::GameWorld& gameWorld() const noexcept {
135 return gameWorld_;
136 }

Referenced by UpdateContext.

inputSnapshot()

const helios::engine::game::InputSnapshot & helios::engine::game::UpdateContext::inputSnapshot ()
inline nodiscard noexcept

Returns the immutable input snapshot for this frame.

Returns

Const ref to the current InputSnapshot.

Definition at line 102 of file UpdateContext.ixx.

102 [[nodiscard]] const helios::engine::game::InputSnapshot& inputSnapshot() const noexcept {
103 assert(inputSnapshot_ && "Unexpected nullptr for InputSnapshot");
104 return *inputSnapshot_;
105 }

pushEvent()

template <typename E, typename... Args>
void helios::engine::game::UpdateContext::pushEvent (Args &&... args)
inline

Pushes an event to the game loop event bus.

This method allows systems and components to publish events during their update phase. Events are buffered and processed in a subsequent phase (N+1) of the game loop, ensuring decoupled communication between systems.

Template Parameters
E

The event type to push.

Args

Constructor argument types for the event.

Parameters
args

Arguments forwarded to the event constructor.

Example usage: ```cpp updateContext.pushEvent<CollisionEvent>(entityA, entityB, contactPoint); ```

Definition at line 156 of file UpdateContext.ixx.

156 void pushEvent(Args&&... args) {
157 eventSink_.template push<E>(std::forward<Args>(args)...);
158 }

setDeltaTime()

UpdateContext & helios::engine::game::UpdateContext::setDeltaTime (float dt)
inline noexcept

Sets the time elapsed since the last frame.

Parameters
dt

Delta time in seconds. Must be non-negative.

Returns

A reference to this UpdateContext instance.

Definition at line 91 of file UpdateContext.ixx.

91 UpdateContext& setDeltaTime(float dt) noexcept {
92 deltaTime_ = dt;
93
94 return *this;
95 }

Reference UpdateContext.

setInputSnapshot()

UpdateContext & helios::engine::game::UpdateContext::setInputSnapshot (const helios::engine::game::InputSnapshot & snapshot)
inline noexcept

Sets the input snapshot for this frame.

Parameters
snapshot

Const ref to the input snapshot.

Returns

A reference to this UpdateContext instance.

Definition at line 114 of file UpdateContext.ixx.

115 inputSnapshot_ = &snapshot;
116
117 return *this;
118 }

Reference UpdateContext.

Private Member Attributes

commandBuffer_

helios::engine::game::CommandBuffer& helios::engine::game::UpdateContext::commandBuffer_

Buffer for queueing commands to be executed at end of frame.

Definition at line 44 of file UpdateContext.ixx.

deltaTime_

float helios::engine::game::UpdateContext::deltaTime_ = 0.0f

Time elapsed since the last frame, in seconds.

Definition at line 34 of file UpdateContext.ixx.

34 float deltaTime_ = 0.0f;

eventSink_

helios::engine::game::event::GameLoopEventSink helios::engine::game::UpdateContext::eventSink_

Sink for pushing game loop events during update.

Used by systems and components to publish events (e.g., collision, spawn requests) that will be processed in a later phase (N+1) of the game loop.

Definition at line 57 of file UpdateContext.ixx.

gameWorld_

helios::engine::game::GameWorld& helios::engine::game::UpdateContext::gameWorld_

Reference to the game world for entity lookups.

Definition at line 49 of file UpdateContext.ixx.

inputSnapshot_

const helios::engine::game::InputSnapshot* helios::engine::game::UpdateContext::inputSnapshot_ = nullptr

Immutable snapshot of input state for the current frame.

Definition at line 39 of file UpdateContext.ixx.

39 const helios::engine::game::InputSnapshot* inputSnapshot_ = nullptr;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.