Skip to main content

GameTimerUpdateSystem.ixx File

System that advances all game timers each frame. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespacemechanics

High-level gameplay systems and components for game logic. More...

namespacetiming

Game timer management system. More...

namespacesystems

Systems for the timing module. More...

Classes Index

classGameTimerUpdateSystem

Updates all game timers managed by the TimerManager. More...

Description

System that advances all game timers each frame.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file GameTimerUpdateSystem.ixx
3 * @brief System that advances all game timers each frame.
4 */
5module;
6
7
8export module helios.engine.mechanics.timing.systems.GameTimerUpdateSystem;
9
10import helios.engine.mechanics.timing.GameTimer;
11import helios.engine.mechanics.timing.TimerManager;
12
13import helios.engine.state.Bindings;
14import helios.engine.runtime.messaging.command.EngineCommandBuffer;
15
16import helios.engine.runtime.world.UpdateContext;
17
18import helios.engine.common.tags.SystemRole;
19
20import helios.engine.mechanics.timing.types;
21import helios.engine.mechanics.timing.commands;
22
24
27
29
30 /**
31 * @brief Updates all game timers managed by the TimerManager.
32 *
33 * Each frame, this system iterates over all registered timers and
34 * advances their elapsed time by the current delta time.
35 *
36 * @see TimerManager
37 * @see GameTimer
38 */
40
41 /**
42 * @brief Reference to the TimerManager owning the timers.
43 */
44 TimerManager& timerManager_;
45
46 public:
47
48
50
51
52 /**
53 * @brief Constructs the system with a reference to the TimerManager.
54 *
55 * @param timerManager The manager whose timers are updated.
56 */
57 explicit GameTimerUpdateSystem(TimerManager& timerManager)
58 : timerManager_(timerManager) {}
59
60 /**
61 * @brief Advances all game timers by the current delta time.
62 *
63 * @param updateContext The current frame's update context.
64 */
66
67 for (auto& gameTimer : timerManager_.gameTimers()) {
68 if (gameTimer.state() == TimerState::Running) {
69
70 gameTimer.update(updateContext.deltaTime());
71
72 if (gameTimer.duration() != 0.0f && gameTimer.elapsed() >= gameTimer.duration()) {
73 auto context = TimerControlContext{gameTimer.gameTimerId(), TimerState::Finished};
74 updateContext.queueCommand<TimerControlCommand>(context);
75 }
76 }
77 }
78 }
79
80 };
81
82}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.