On this page
  1. Fields

rmp::behavior::Timer

behavior #include <rmp/behavior.h> include/rmp/behavior.h:434
struct Timer

Calls you every N seconds. Shooting, blinking, a countdown.

Added to an object with add<rmp::behavior::Timer>(); the framework calls its _update with the object it is on.

Fields

FieldTypeDefaultWhat it is
secondsfloat1

Between calls; 0 = it never fires

repeatbooltrue

False = one call, and then it is spent

on_timeoutCallback<Object &>

Called with the object the Timer is on. A frame longer than seconds calls it once for every interval that frame covered, so a countdown keeps time on a slow machine — up to a thousand: more than that owed in one frame is an interval far shorter than any frame, and the rest of the time is dropped and said once.

oursstruct { … }

What it is keeping track of. Readable, because sometimes you want it; not yours to write. It is one PUBLIC member and not a private block because a struct with a private member is not an aggregate in C++20, and then { .speed = 320 } stops compiling — which is the whole design. The name is the fence.