bevy-events-messaging
Installation
SKILL.md
Bevy events and messaging
When to use
Load this when one system should notice that something happened without storing that fact on every entity. Pick the mechanism from the pages below. Do not invent a third channel.
ECS shape
- Messages (pull).
Messageis a buffered message for pull-based handling.MessageWriterwrites.MessageReaderreads and tracks what it already saw.Messagesholds what occurred within the last two updates. Register the type withApp::add_message. The engine updates the buffer; gameplay systems only write and read. - Events (push). Derive
Event, add an observer, trigger.Commands::triggerandWorld::triggerrun observers immediately inside the call.On<E>is the system parameter.Event::Triggerdefaults toGlobalTriggerfor derived events. - Observers. An
Observeris a component that holds a system.EntityEventtargets one entity: the event carries theentityfield, andOn::event_targetreturns it. - State transitions.
StateTransitionEvent<S>fires when stateSchanges. That type lives with states. See bevy-state-machines.
Examples
[dependencies]
bevy = "0.20"