rmp::behavior::StateMachine
Named states and the moves between them: an enemy that idles, patrols, chases and flees; a boss's phases. It starts in initial at its first update, asks the transitions in order every frame — the first whose from matches and whose when says yes is taken — and runs the state's on_update. go() moves by name, at its next update.
Added to an object with add<rmp::behavior::StateMachine>(); the framework calls its _update with the object it is on.
Fields
| Field | Type | Default | What it is |
|---|---|---|---|
states | std::vector<State> | Every state it can be in, by name | |
initial | std::string | "" = the first state | |
transitions | std::vector<Transition> | Asked in order; the first that says yes is taken | |
ours | struct { … } | 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 |
go
Moves to the state called name at its next update; a name it does not have is said once and changes nothing.
state
The state it is in; "" before its first update.
seconds_in_state
How long it has been in it, in seconds.