rmp::behavior::Collectible
A coin, a key, a heart. Touched by an object on a layer of collected_by, it calls on_collect, plays its sound, stops colliding and vanishes — it rises, grows and fades for vanish_seconds — and is destroyed. Within magnet of a collector it flies to it first. What a coin is worth is the game's: on_collect is where it counts.
From the editor: "magnet" (Float).
Added to an object with add<rmp::behavior::Collectible>(); the framework calls its _update, _collision with the object it is on.
Fields
| Field | Type | Default | What it is |
|---|---|---|---|
collected_by | unsigned | 0xFFFFFFFFu | The layers that pick it up |
sound | std::string | Played by | |
magnet | float | 0 | Within this many units of a collector it flies to it; 0 = never |
magnet_speed | float | 360 | How fast, in units per second |
vanish_seconds | float | 0.25f | How long it takes to go; 0 = at once |
on_collect | Callback<Object &, Object &> | (the pickup, who picked it up), once | |
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 |
collected
Whether it has been picked up: from then on it only vanishes.
from
A Collectible with the fields the map's entity has by these names — magnet — and the defaults for the rest. See "FROM THE EDITOR" at the top of this file.