On this page
  1. Fields
    1. overlapping
    2. contains

rmp::behavior::Area

behavior #include <rmp/behavior.h> include/rmp/behavior.h:554
struct 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 left

An 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

FieldTypeDefaultWhat it is
on_enterCallback<Object &, Object &>

(the area, who came in)

on_stayCallback<Object &, Object &>

(the area, who is still touching)

on_exitCallback<Object &, Object &>

(the area, who left)

on_insideCallback<Object &, Object &>

(the area, who is wholly inside now)

on_outsideCallback<Object &, Object &>

(the area, who is no longer wholly inside)

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.

overlapping

std::span<const Handle<Object>> overlapping() const

Who touched it in the last collision pass, as handles: one destroyed since then reads empty.

contains

bool contains(const Object &other) const

Whether other touched it in the last collision pass.