annotation
@On
@On(Event) handler Name { … }
@On(Event) turns a handler into a listener for a named event: whenever any code runs emit Event(...), this handler's body runs with the event's fields bound by name. It is how systems talk to each other without referencing one another directly — the emitter never knows who is listening, so gameplay, UI and mods can all react to the same moment independently. Several handlers may listen to one event; they run in declaration order. On a cancellable event, a listener may cancel to veto it, and the emitter sees that outcome. Related lifecycle hooks such as @OnSpawn, @OnEnable and @OnDespawn are specialized event listeners the compiler wires up for you.
Example
program Events {
property Health { current: int = 100, maximum: int = 100 }
model Player { Health }
event Damaged { amount: int = 0 }
handler SpawnPlayer phase Start {
spawn Player { Health { current: 100, maximum: 100 } }
emit Damaged(amount: 25)
}
@On(Damaged)
handler ReportDamage {
print(amount)
}
}