dao::clock
Pause or speed up the game’s clock for effects, regeneration and their timers.
Declared in dao/Clock.h.
Classes
| Class | |
|---|---|
| WorldTime | The world’s clock at a moment: the game’s calendar day and the time into it. |
Functions
Advance()
void Advance(float seconds)
Moves effects, regeneration and timers on by an amount of time, in one step.
On its next update, each effect ages and each creature regenerates by that much extra time, and the timers that fall due fire in order. This works while the clock is held. Objects on their own clocks (OwnClock) are left out.
| Parameter | |
|---|---|
seconds |
the time to add, in game seconds |
AdvanceObject()
void AdvanceObject(ObjectId object, float seconds)
Moves one object’s own clock (see OwnClock) on.
| Parameter | |
|---|---|
seconds |
the time to add, in game seconds; fractions of a millisecond carry over |
Held()
bool Held()
Returns whether the clock is held.
Hold()
void Hold(bool held)
Stops effects from wearing off and creatures from regenerating, and holds the timers that pace effects; or lets all of them run again.
While the clock is held, only Advance moves them on. Cooldowns still run, and so do the timers that dao/Timers.h does not hold. A creature held by an effect, such as a pin or a knockdown, stays held until the clock is advanced past the effect or the effect is removed. Hold(false) returns every object given to OwnClock to the shared clock.
| Parameter | |
|---|---|
held |
true to stop them, false to let them run |
Now()
std::optional<WorldTime> Now()
Returns the world’s clock now, the one a save writes and a load restores, or nullopt before the game is up.
It runs at the game’s speed (SetSpeed), and a load sets it to the save’s time. Call it on the game thread.
OwnClock()
void OwnClock(ObjectId object, bool own=true)
Puts a creature’s effects, regeneration and timers on a clock of their own, or back on the shared clock.
Advance then leaves the object out, and AdvanceObject moves its clock on. Hold(false) returns every object to the shared clock.
dao::clock::Hold(true);
dao::clock::OwnClock(creature); // for each combatant
dao::clock::AdvanceObject(creature, 0.016f); // as its turn is spent
dao::clock::Advance(4.0f); // each round, for areas and bystanders
dao::clock::Hold(false);
| Parameter | |
|---|---|
object |
the creature, or any other object |
own |
true for its own clock, false for the shared one |
SetSpeed()
bool SetSpeed(float scale, float seconds=0.0F)
Sets how fast the game runs, using the same time scale as the game’s own slow motion.
Call it on the game thread. It changes the speed of the game’s logic and animation, but not of the Flash interface. All plugins share one speed, and the last one set wins.
| Parameter | |
|---|---|
scale |
the speed: 1 for normal, 0.5 for half speed, 2 for double speed |
seconds |
how long to ease from the current speed to the new one; 0 to change at once |
Returns false, with nothing changed, if the game is not up yet, if scale is 0 or less, or if seconds is negative
Speed()
float Speed()
Returns the speed last set, or 1 if none has been set.