Skip to main content

UpdateContext.ixx File

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

Included Headers

#include <span> #include <cassert> #include <helios.engine.runtime.world.EngineWorld> #include <helios.engine.runtime.world.Session> #include <helios.ecs.View> #include <helios.engine.runtime.world.RuntimeEnvironment> #include <helios.engine.runtime.messaging.event.GameLoopEventBus> #include <helios.ecs.types.EntityHandle> #include <helios.engine.runtime.world.Level> #include <helios.engine.input.InputSnapshot>

Namespaces Index

namespacehelios
namespaceengine
namespaceruntime
namespaceworld

Classes Index

classUpdateContext

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

Description

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

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <span>
8#include <cassert>
9
10export module helios.engine.runtime.world.UpdateContext;
11
12import helios.engine.input.InputSnapshot;
13
14import helios.engine.runtime.world.Level;
15import helios.engine.runtime.messaging.event.GameLoopEventBus;
16
17import helios.engine.runtime.world.RuntimeEnvironment;
18import helios.ecs.types.EntityHandle;
19
20import helios.ecs.View;
21import helios.engine.runtime.world.Session;
22
23
24import helios.engine.runtime.world.EngineWorld;
25
26export namespace helios::engine::runtime::world {
27
28
47
48 private:
52 float deltaTime_ = 0.0f;
53
57 float totalTime_ = 0.0f;
58
62 const helios::engine::input::InputSnapshot& inputSnapshot_;
63
68
73
80 helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink phaseEventSink_;
81
85 const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource phaseEventSource_;
86
93 helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink passEventSink_;
94
98 const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource passEventSource_;
99
107 helios::engine::runtime::messaging::event::GameLoopEventBus::WriteSink frameEventSink_;
108
112 const helios::engine::runtime::messaging::event::GameLoopEventBus::ReadSource frameEventSource_;
113
117 const Level* level_;
118
123 public:
124
125
144 const float deltaTime,
145 const float totalTime,
150 const Level* level,
151 EngineWorld& engineWorld
152 ) :
153 session_(session),
154 runtimeEnvironment_(runtimeEnvironment),
155 deltaTime_(deltaTime),
156 totalTime_(totalTime),
157 phaseEventSink_(phaseEventBus.writeSink()),
158 phaseEventSource_(phaseEventBus.readSource()),
159 passEventSink_(passEventBus.writeSink()),
160 passEventSource_(passEventBus.readSource()),
161 frameEventSink_(frameEventBus.writeSink()),
162 frameEventSource_(frameEventBus.readSource()),
163 inputSnapshot_(inputSnapshot),
164 level_(level),
165 engineWorld_(engineWorld)
166 {
167
168 }
169
170
171
178 return deltaTime_;
179 }
180
187 return totalTime_;
188 }
189
196 return inputSnapshot_;
197 }
198
208 template<typename THandle>
209 [[nodiscard]] auto find(const THandle handle) noexcept {
210 return engineWorld_.template find<THandle>(handle);
211 }
212
213
220 return level_;
221 }
222
223
230 return session_;
231 }
232
239 return runtimeEnvironment_;
240 }
241
256 template<typename E, typename... Args>
257 void pushPass(Args&&... args) {
258 passEventSink_.template push<E>(std::forward<Args>(args)...);
259 }
260
275 template<typename E, typename... Args>
276 void pushPhase(Args&&... args) {
277 phaseEventSink_.template push<E>(std::forward<Args>(args)...);
278 }
279
294 template<typename E>
295 std::span<const E> readPhase() {
296 return phaseEventSource_.template read<E>();
297 }
298
313 template<typename E>
314 std::span<const E> readPass() {
315 return passEventSource_.template read<E>();
316 }
317
337 template<typename E>
338 std::span<const E> readFrame() {
339 return frameEventSource_.template read<E>();
340 }
341
360 template<typename E, typename... Args>
361 void pushFrame(Args&&... args) {
362 frameEventSink_.template push<E>(std::forward<Args>(args)...);
363 }
364
365
374 template <typename THandle, typename... Components>
375 [[nodiscard]] auto view() {
376 return engineWorld_.view<THandle, Components...>();
377 }
378
379
380
381 };
382}
383

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.