|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
Engine::Core::TimerManager schedules one-shot callbacks against engine time. Use it for delayed gameplay work that does not need a per-frame tick() override.
Creates a standalone timer manager.
Standalone managers use the last value passed to tick(nowSeconds) as their current time base. Use this form for tools or isolated systems that drive time manually.
Example:
Creates a timer manager that reads current time from Engine::EngineKern.
Engine users normally access this instance through Engine::EngineKern::getTimerManager().
Parameters:
Opaque identifier returned when a timer is scheduled.
A default-constructed handle is invalid. cancelTimer() ignores invalid handles and handles for timers that already fired.
Example:
Schedules an unowned one-shot callback.
Use this for callbacks whose captured data outlives the timer, or cancel the handle before the captured data is destroyed. Prefer setActorTimer() for actor-owned gameplay logic.
Parameters:
Returns: A TimerHandle that can cancel the timer before it fires.
Example:
Schedules a one-shot callback tied to an actor.
The callback runs only while owner is still backed by a valid ECS entity. Passing nullptr returns an invalid handle and schedules no timer.
Parameters:
Returns: A TimerHandle that can cancel the timer before it fires.
Example:
Cancels one scheduled timer.
Invalid handles, unknown handles, and handles for already-fired timers are ignored.
Parameters:
Example:
Cancels every actor-owned timer registered for owner.
Passing nullptr is ignored. Engine::Entities::Actor cancels its actor timers during end play.
Parameters:
Example:
Removes all pending timers without running callbacks.
Use this when shutting down a timer manager or resetting a manually-owned timer set.
Example:
Executes all timers due at or before nowSeconds.
Game code normally does not call this on the engine-owned manager. The engine ticks its manager after postTick() callbacks and before pending actor destruction is flushed.
Timers scheduled for the same fire time run in creation order. Timers scheduled by a callback for the current time can run during the same tick() call.
Parameters:
Example:
Call setActorTimer() from actor-owned gameplay logic. The callback receives the owning actor as a reference after the timer validates its ECS entity.
Timers are one-shot. Schedule the next timer from the callback to repeat work.
Store the handle when the timer controls a named state transition. Cancel the previous handle before scheduling a replacement.
| Case | Behavior |
|---|---|
| Negative delay | Treated as 0.0 seconds. |
| Empty callback | Timer fires and performs no callback work. |
| Invalid TimerHandle | cancelTimer() ignores it. |
| nullptr actor owner | setActorTimer() returns an invalid handle. |
| Destroyed actor owner | Pending actor timer is skipped. |
| Same fire time | Timers run in creation order. |
| Callback schedules a due timer | The new timer can run in the same tick(). |
| Callback cancels another timer | The canceled timer is removed if it has not fired. |