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.gameloop.PassCommitListener>
#include <helios.rendering.ViewportSnapshot>
#include <helios.input.InputSnapshot>
#include <helios.engine.runtime.world.Manager>
#include <helios.engine.runtime.world.UpdateContext>
#include <helios.engine.state.Bindings>
#include <helios.engine.mechanics.gamestate.types>
#include <helios.util.log.LogManager>
#include <helios.engine.runtime.gameloop.CommitPoint>
#include <helios.engine.ecs>
#include <helios.engine.mechanics.match.types>
#include <helios.engine.runtime.world.GameWorld>
#include <helios.engine.runtime.messaging.command.EngineCommandBuffer>
#include <helios.engine.runtime.messaging.event.GameLoopEventBus>
#include <helios.util.log.Logger>
#include <helios.engine.runtime.gameloop.Phase>
Namespaces Index
| namespace | helios |
| namespace | engine |
|
Main engine module aggregating core infrastructure and game systems. More... | |
| namespace | runtime |
|
Runtime infrastructure for game execution and lifecycle orchestration. More... | |
| namespace | gameloop |
|
Central game loop orchestration module. More... | |
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 44 of file GameLoop.ixx.
44#define HELIOS_LOG_SCOPE "helios::engine::runtime::gameloop::GameLoop"
File Listing
The file content with the documentation metadata removed is:
42using namespace helios::engine::runtime::world;
44#define HELIOS_LOG_SCOPE "helios::engine::runtime::gameloop::GameLoop"
45export namespace helios::engine::runtime::gameloop {
94 class GameLoop : public helios::engine::runtime::gameloop::PassCommitListener {
111 inline static const helios::util::log::Logger& logger_ = helios::util::log::LogManager::loggerForScope(
112 HELIOS_LOG_SCOPE);
175 float totalTime_ = 0.0f;
202 void onPassCommit(
203 const CommitPoint commitPoint,
204 GameWorld& gameWorld,
205 UpdateContext& updateContext) noexcept override {
208 if ((commitPoint & CommitPoint::FlushCommands) == CommitPoint::FlushCommands) {
212 if ((commitPoint & CommitPoint::FlushManagers) == CommitPoint::FlushManagers) {
217 if ((commitPoint & CommitPoint::PassEvents) == CommitPoint::PassEvents) {
218 passEventBus_.swapBuffers();
239 void phaseCommit(
240 GameWorld& gameWorld,
241 UpdateContext& updateContext) {
243 passEventBus_.clearAll();
246 gameWorld.flushCommandBuffers(updateContext);
249 gameWorld.flushManagers(updateContext);
252 phaseEventBus_.swapBuffers();
275 [[nodiscard]] helios::engine::runtime::gameloop::Phase& phase(const helios::engine::runtime::gameloop::PhaseType phaseType) noexcept {
279 return prePhase_;
282 return mainPhase_;
285 return postPhase_;
316 for (auto phase : {helios::engine::runtime::gameloop::PhaseType::Pre,
319 switch (phase) {
321 prePhase_.init(gameWorld);
322 prePhase_.addPassCommitListener(this);
325 mainPhase_.init(gameWorld);
326 mainPhase_.addPassCommitListener(this);
329 postPhase_.init(gameWorld);
330 postPhase_.addPassCommitListener(this);
369 GameWorld& gameWorld,
371 const helios::input::InputSnapshot& inputSnapshot,
377 totalTime_ += deltaTime;
379 auto updateContext = UpdateContext(
381 helios::engine::ecs::EntityResolver(&gameWorld.entityManager()),
384 totalTime_,
385 phaseEventBus_,
386 passEventBus_,
387 frameEventBus_,
396 for (auto phase : {helios::engine::runtime::gameloop::PhaseType::Pre,
400 switch (phase) {
402 prePhase_.update(gameWorld, updateContext);
403 phaseCommit(gameWorld, updateContext);
407 mainPhase_.update(gameWorld, updateContext);
408 phaseCommit(gameWorld, updateContext);
412 postPhase_.update(gameWorld, updateContext);
413 phaseCommit(gameWorld, updateContext);
414 frameEventBus_.swapBuffers();
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.