onTraitAdd
onTraitAdd(
writer,trait,listener): () =>void
Calls listener with each entity that gains trait, as it gains it,
and with the world’s authority where the world decides outcomes, null on
a page in a room. A plugin’s setup registers this to answer an entity’s
arrival at once, such as a match that scores only the coins credited
after it spawned. It takes the setup writer, so only a setup or a setup
effect registers one, and returns the call that stops it, which the
setup returns. An entity that gains it while a player’s join runs, such
as one an onPlayerJoin hook spawns, is handed over once the player’s
join ends, where it still holds the trait. The listener writes with the
world’s authority and a refused join leaves it nothing to take back. As
Bevy’s OnAdd observer, handed Commands.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
writer |
SetupWriter |
trait |
Trait |
listener |
(entity, authority) => void |
Returns
Section titled “Returns”() => void