bevy_ecs::event

Trait Event

Source
pub trait Event: Component {
    type Traversal: Traversal;

    const AUTO_PROPAGATE: bool = false;
}
Expand description

Something that “happens” and might be read / observed by app logic.

Events can be stored in an Events<E> resource You can conveniently access events using the EventReader and EventWriter system parameter.

Events can also be “triggered” on a World, which will then cause any Observer of that trigger to run.

This trait can be derived.

Events implement the Component type (and they automatically do when they are derived). Events are (generally) not directly inserted as components. More often, the ComponentId is used to identify the event type within the context of the ECS.

Events must be thread-safe.

Provided Associated Constants§

Source

const AUTO_PROPAGATE: bool = false

When true, this event will always attempt to propagate when triggered, without requiring a call to Trigger::propagate.

Required Associated Types§

Source

type Traversal: Traversal

The component that describes which Entity to propagate this event to next, when propagation is enabled.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Event for RemovedComponentEntity
where Self: Send + Sync + 'static,

Source§

impl Event for OnAdd
where Self: Send + Sync + 'static,

Source§

impl Event for OnInsert
where Self: Send + Sync + 'static,

Source§

impl Event for OnRemove
where Self: Send + Sync + 'static,

Source§

impl Event for OnReplace
where Self: Send + Sync + 'static,