# rmp::behavior::Area

> A region that says who comes and goes: a trigger, a door's sensor, a pit, a shop's counter.

Source: https://omardev29.github.io/rmp-docs/reference/behaviors/Area.html

behavior `#include <rmp/behavior.h>` [include/rmp/behavior.h:554](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L554-L583)

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).

```cpp
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:

```text
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

| 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 `{ .speed = 320 }` stops compiling — which is the whole design. The name is the fence. |

### `overlapping`

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

function [include/rmp/behavior.h:563](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L563-L565)

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

### `contains`

bool contains(const Object &other) const

function [include/rmp/behavior.h:567](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L567)

Whether `other` touched it in the last collision pass.
