Fires every period seconds (a tower that shoots, a wave every 30 s), or once after a delay (a bomb, a message that goes away).
More...
#include <aegis2d/ecs/timers.hpp>
|
| static constexpr Timer | every (float seconds) noexcept |
| | A timer that fires every seconds, the first time seconds from now.
|
| |
| static constexpr Timer | after (float seconds) noexcept |
| | A timer that fires once, seconds from now.
|
| |
|
| float | period = 1.0F |
| | Seconds between two fires of a repeating timer; not used by a one-shot one.
|
| |
| float | left = 1.0F |
| | Seconds before the next fire.
|
| |
| bool | repeat = true |
| | true to fire every period, false to fire once.
|
| |
| bool | running = true |
| | false while paused: the time does not run.
|
| |
| bool | done = false |
| | true once a one-shot timer has fired; it never fires again.
|
| |
Fires every period seconds (a tower that shoots, a wave every 30 s), or once after a delay (a bomb, a message that goes away).
fire_timers() counts left down each tick and lists the entity each time it reaches zero. A repeating timer then adds its period to left, keeping the time left over, so it fires exactly 1 / period times per second whatever the tick rate; a one-shot timer is done and stays so. Create one with every() or after(), or set the fields: left is the delay before the first fire, 0 to fire on the next tick.
◆ after()
| static constexpr Timer aegis2d::ecs::Timer::after |
( |
float |
seconds | ) |
|
|
inlinestaticconstexprnoexcept |
A timer that fires once, seconds from now.
- Parameters
-
| seconds | Delay; 0 or less fires on the next tick. |
- Returns
- The timer.
◆ every()
| static constexpr Timer aegis2d::ecs::Timer::every |
( |
float |
seconds | ) |
|
|
inlinestaticconstexprnoexcept |
A timer that fires every seconds, the first time seconds from now.
- Parameters
-
- Returns
- The timer.
◆ done
| bool aegis2d::ecs::Timer::done = false |
true once a one-shot timer has fired; it never fires again.
◆ left
| float aegis2d::ecs::Timer::left = 1.0F |
Seconds before the next fire.
◆ period
| float aegis2d::ecs::Timer::period = 1.0F |
Seconds between two fires of a repeating timer; not used by a one-shot one.
◆ repeat
| bool aegis2d::ecs::Timer::repeat = true |
true to fire every period, false to fire once.
◆ running
| bool aegis2d::ecs::Timer::running = true |
false while paused: the time does not run.
The documentation for this struct was generated from the following file: