UpdateContext Struct
Context passed to Updatable components during per-frame updates. More...
Declaration
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
| float | deltaTime () 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> | |
| void | pushEvent (Args &&... args) |
|
Pushes an event to the game loop event bus. More... | |
Private Member Attributes Index
| float | deltaTime_ = 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::GameLoopEventSink | eventSink_ |
|
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()
| 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()
| 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.
Referenced by UpdateContext.
deltaTime()
| inline nodiscard noexcept |
Returns the time elapsed since the last frame, in seconds.
Definition at line 80 of file UpdateContext.ixx.
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.
Referenced by 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.
pushEvent()
| 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.
setDeltaTime()
| 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.
Reference UpdateContext.
setInputSnapshot()
| 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.
Reference UpdateContext.
Private Member Attributes
commandBuffer_
|
Buffer for queueing commands to be executed at end of frame.
Definition at line 44 of file UpdateContext.ixx.
deltaTime_
|
Time elapsed since the last frame, in seconds.
Definition at line 34 of file UpdateContext.ixx.
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_
|
Reference to the game world for entity lookups.
Definition at line 49 of file UpdateContext.ixx.
inputSnapshot_
|
Immutable snapshot of input state for the current frame.
Definition at line 39 of file UpdateContext.ixx.
The documentation for this struct was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.