Skip to main content

GameLoop.ixx File

Central orchestrator for the game update cycle. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine
namespaceruntime
namespacegameloop

Classes Index

classGameLoop

Central orchestrator for the game update cycle. More...

Macro Definitions Index

#defineHELIOS_LOG_SCOPE   "helios::engine::runtime::gameloop::GameLoop"

Description

Central orchestrator for the game update cycle.

Macro Definitions

HELIOS_LOG_SCOPE

#define HELIOS_LOG_SCOPE   "helios::engine::runtime::gameloop::GameLoop"

Definition at line 38 of file GameLoop.ixx.

38#define HELIOS_LOG_SCOPE "helios::engine::runtime::gameloop::GameLoop"

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <cassert>
8#include <memory>
9#include <vector>
10#include <span>
11
12export module helios.engine.runtime.gameloop:GameLoop;
13
14import helios.engine.runtime.world.GameWorld;
15
16import helios.engine.runtime.world.UpdateContext;
17import helios.engine.util.log.Logger;
18import helios.engine.util.log.LogManager;
19
20import helios.ecs;
21
22import helios.engine.runtime.messaging.event.GameLoopEventBus;
23
24import helios.engine.runtime.enginestate.types;
25
26import :CommitPoint;
27import :Phase;
28import :PassCommitListener;
29
30import helios.engine.runtime.world.Manager;
31
32import helios.engine.input.InputSnapshot;
33
34import helios.engine.runtime.world.GameWorld;
35
37
38#define HELIOS_LOG_SCOPE "helios::engine::runtime::gameloop::GameLoop"
40
89
90
97 bool initialized_ = false;
98 protected:
99
100
101
108
109
114
119
124
125
137
150
166
170 float totalTime_ = 0.0f;
171
172
173
199 const CommitPoint commitPoint,
201 UpdateContext& updateContext) noexcept {
202
203 // commands must be executed before Managers
206 }
207
210 }
211
212 // managers might create pass events
213 if ((commitPoint & CommitPoint::PassEvents) == CommitPoint::PassEvents) {
215 }
216
217 }
218
238
240
241 // command buffers generate requests for managers, so this comes first
243
244 // managers process requests
246
247 // make sure flushed managers make their events available to the phase event bus
249 }
250
251
252 public:
253
254
265
266
275
276 switch (phaseType) {
278 return prePhase_;
279 break;
281 return mainPhase_;
282 break;
284 return postPhase_;
285 break;
286 }
287
288 std::unreachable();
289
290 }
291
292
312
313 assert(!initialized_ && "init() already called");
314
315 prePhase_.init(gameWorld);
317
320
323
324 initialized_ = true;
325 }
326
328 return gameWorld_;
329 }
330
361 void update(
363 float deltaTime,
364 const helios::engine::input::InputSnapshot& inputSnapshot
365 ) noexcept {
366
367 assert(initialized_ && "GameLoop not initialized");
368
369 totalTime_ += deltaTime;
370
374 deltaTime,
379 inputSnapshot,
382 );
383
384 auto& session = gameWorld.session();
385
386 // gameloop phases
389
392
396 }
397
398 [[nodiscard]] bool isRunning( GameWorld& gameWorld) const noexcept {
399 return initialized_ && !gameWorld.session().isDestroyed();
400 }
401
402
403
404 };
405
406}
407

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.