rmp::behavior::Area
A region that says who comes and goes: a trigger, a door's sensor, a pit, a shop's counter. It is the object it is on — its collider, its layers — so it sees what that object collides with, and solid or not is the object's business (a trigger is not solid, which is the default).
door.collision_mask = layer::PLAYER;
door.add<rmp::behavior::Area>({ .on_enter = [](rmp::Object &, rmp::Object &who) {
open_the_door(who);
} });Five moments, each told with the area and the other object:
on_enter the first frame the other touches it
on_stay every frame after that it still does
on_exit the frame after the first one it no longer does
on_inside its collider is wholly inside the area's, from a frame it was not
on_outside it is no longer wholly inside: part of it is out, or it leftAn object destroyed while it touches the area leaves overlapping() and is told nothing: it is gone, and there is no object to hand over.
Added to an object with add<rmp::behavior::Area>(); the framework calls its _update, _collision with the object it is on.
Fields
| Field | Type | Default | What it is |
|---|---|---|---|
on_enter | Callback<Object &, Object &> | (the area, who came in) | |
on_stay | Callback<Object &, Object &> | (the area, who is still touching) | |
on_exit | Callback<Object &, Object &> | (the area, who left) | |
on_inside | Callback<Object &, Object &> | (the area, who is wholly inside now) | |
on_outside | Callback<Object &, Object &> | (the area, who is no longer wholly inside) | |
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 |
overlapping
Who touched it in the last collision pass, as handles: one destroyed since then reads empty.
contains
Whether other touched it in the last collision pass.