GameTimer Class
A game timer identified by a GameTimerId. More...
Declaration
Public Constructors Index
| GameTimer (const helios::engine::core::data::GameTimerId gameTimerId) | |
Public Member Functions Index
| helios::engine::core::data::GameTimerId | gameTimerId () const noexcept |
|
Returns the timer identifier. More... | |
| void | reset () noexcept |
|
Resets the elapsed time to zero. More... | |
| void | setDuration (float duration) |
|
Sets the duration limit. More... | |
| float | duration () const noexcept |
|
Returns the duration limit. More... | |
| float | elapsed () const noexcept |
|
Returns the accumulated elapsed time. More... | |
| TimerState | state () const noexcept |
|
Returns the current timer state. More... | |
| void | setState (const TimerState state) noexcept |
|
Sets the timer state. More... | |
| bool | shouldUpdate () const noexcept |
|
Returns whether this timer should accumulate time. More... | |
| TimerRevision | timerRevision () const noexcept |
|
Returns the current revision counter. More... | |
| void | update (const float ft) |
|
Advances the timer by the given frame time. More... | |
Private Member Attributes Index
| TimerRevision | timerRevision_ {} |
|
Monotonically increasing revision counter, incremented on each update. More... | |
| GameTimerId | gameTimerId_ |
|
Unique identifier for this timer. More... | |
| float | elapsed_ {} |
|
Accumulated elapsed time in seconds. More... | |
| TimerState | timerState_ {} |
|
Current state of the timer. More... | |
| float | duration_ = 0.0f |
|
Optional duration limit in seconds. More... | |
Description
A game timer identified by a GameTimerId.
Tracks elapsed time while in the Started state. Each update increments a revision counter that observers can use to detect changes.
- See Also
- See Also
GameTimerBindingComponent
Definition at line 27 of file GameTimer.ixx.
Public Constructors
GameTimer()
| inline explicit |
Constructs a GameTimer with the given identifier.
- Parameters
-
gameTimerId The unique identifier for this timer.
Definition at line 61 of file GameTimer.ixx.
Reference gameTimerId.
Public Member Functions
duration()
| inline nodiscard noexcept |
Returns the duration limit.
- Returns
The duration in seconds.
Definition at line 94 of file GameTimer.ixx.
Referenced by setDuration.
elapsed()
| inline nodiscard noexcept |
Returns the accumulated elapsed time.
- Returns
Elapsed time in seconds.
Definition at line 103 of file GameTimer.ixx.
gameTimerId()
| inline nodiscard noexcept |
Returns the timer identifier.
- Returns
The GameTimerId assigned to this timer.
Definition at line 69 of file GameTimer.ixx.
Referenced by GameTimer.
reset()
| inline noexcept |
Resets the elapsed time to zero.
Definition at line 76 of file GameTimer.ixx.
setDuration()
| inline |
Sets the duration limit.
- Parameters
-
duration Duration in seconds.
Definition at line 85 of file GameTimer.ixx.
Reference duration.
setState()
| inline noexcept |
Sets the timer state.
- Parameters
-
state The new TimerState.
Definition at line 121 of file GameTimer.ixx.
Reference state.
shouldUpdate()
| inline nodiscard noexcept |
Returns whether this timer should accumulate time.
- Returns
True if the timer is in the Started state.
Definition at line 130 of file GameTimer.ixx.
Reference helios::engine::mechanics::timing::types::Started.
Referenced by update.
state()
| inline nodiscard noexcept |
Returns the current timer state.
- Returns
The current TimerState.
Definition at line 112 of file GameTimer.ixx.
Referenced by setState.
timerRevision()
| inline nodiscard noexcept |
Returns the current revision counter.
- Returns
The TimerRevision value.
Definition at line 139 of file GameTimer.ixx.
update()
| inline |
Advances the timer by the given frame time.
Only accumulates time when the timer is in the Started state. Increments the revision counter on each successful update.
- Parameters
-
ft Frame time in seconds.
Definition at line 151 of file GameTimer.ixx.
Reference shouldUpdate.
Private Member Attributes
duration_
|
Optional duration limit in seconds.
Definition at line 52 of file GameTimer.ixx.
elapsed_
|
Accumulated elapsed time in seconds.
Definition at line 42 of file GameTimer.ixx.
gameTimerId_
|
Unique identifier for this timer.
Definition at line 37 of file GameTimer.ixx.
timerRevision_
|
Monotonically increasing revision counter, incremented on each update.
Definition at line 32 of file GameTimer.ixx.
timerState_
|
Current state of the timer.
Definition at line 47 of file GameTimer.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.