GameLoop.ixx File
Central orchestrator for the game update cycle. More...
Included Headers
#include <cassert>
#include <memory>
#include <vector>
#include <span>
#include <helios.engine.runtime.world.Manager>
#include <helios.engine.runtime.gameloop:Phase>
#include <helios.engine.runtime.enginestate.types>
#include <helios.engine.runtime.messaging.event.GameLoopEventBus>
#include <helios.engine.runtime.world.GameWorld>
#include <helios.ecs>
#include <helios.engine.util.log.LogManager>
#include <helios.engine.input.InputSnapshot>
#include <helios.engine.util.log.Logger>
#include <helios.engine.runtime.world.UpdateContext>
Namespaces Index
| namespace | helios |
| namespace | engine |
| namespace | runtime |
| namespace | gameloop |
Classes Index
| class | GameLoop |
|
Central orchestrator for the game update cycle. More... | |
Macro Definitions Index
| #define | HELIOS_LOG_SCOPE "helios::engine::runtime::gameloop::GameLoop" |
Description
Central orchestrator for the game update cycle.
Macro Definitions
HELIOS_LOG_SCOPE
|
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:
36using namespace helios::engine::runtime::world;
38#define HELIOS_LOG_SCOPE "helios::engine::runtime::gameloop::GameLoop"
39export namespace helios::engine::runtime::gameloop {
88 class GameLoop : public helios::engine::runtime::gameloop::PassCommitListener {
105 inline static const helios::engine::util::log::Logger& logger_ = helios::engine::util::log::LogManager::loggerForScope(
106 HELIOS_LOG_SCOPE);
170 float totalTime_ = 0.0f;
198 void onPassCommit(
199 const CommitPoint commitPoint,
201 UpdateContext& updateContext) noexcept {
204 if ((commitPoint & CommitPoint::FlushCommands) == CommitPoint::FlushCommands) {
208 if ((commitPoint & CommitPoint::FlushManagers) == CommitPoint::FlushManagers) {
213 if ((commitPoint & CommitPoint::PassEvents) == CommitPoint::PassEvents) {
214 passEventBus_.swapBuffers();
235 void phaseCommit(
237 UpdateContext& updateContext) {
239 passEventBus_.clearAll();
248 phaseEventBus_.swapBuffers();
264 GameLoop(GameWorld& gameWorld) : gameWorld_(gameWorld), prePhase_(*this, gameWorld_), mainPhase_(*this, gameWorld_), postPhase_(*this, gameWorld_) {};
274 [[nodiscard]] helios::engine::runtime::gameloop::Phase& phase(const helios::engine::runtime::gameloop::PhaseType phaseType) noexcept {
276 switch (phaseType) {
278 return prePhase_;
281 return mainPhase_;
284 return postPhase_;
313 assert(!initialized_ && "init() already called");
316 prePhase_.addPassCommitListener(this);
318 mainPhase_.init(gameWorld);
319 mainPhase_.addPassCommitListener(this);
321 postPhase_.init(gameWorld);
322 postPhase_.addPassCommitListener(this);
328 return gameWorld_;
364 const helios::engine::input::InputSnapshot& inputSnapshot
367 assert(initialized_ && "GameLoop not initialized");
369 totalTime_ += deltaTime;
371 auto updateContext = UpdateContext(
373 gameWorld.runtimeEnvironment(),
375 totalTime_,
376 phaseEventBus_,
377 passEventBus_,
378 frameEventBus_,
381 gameWorld.engineWorld()
387 prePhase_.update(gameWorld, updateContext);
388 phaseCommit(gameWorld, updateContext);
390 mainPhase_.update(gameWorld, updateContext);
391 phaseCommit(gameWorld, updateContext);
393 postPhase_.update(gameWorld, updateContext);
394 phaseCommit(gameWorld, updateContext);
395 frameEventBus_.swapBuffers();
399 return initialized_ && !gameWorld.session().isDestroyed();
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.