bevy_ecs/event/
send_event.rs

1use super::{Event, Events};
2use crate::world::{Command, World};
3
4/// A command to send an arbitrary [`Event`], used by [`Commands::send_event`](crate::system::Commands::send_event).
5pub struct SendEvent<E: Event> {
6    /// The event to send.
7    pub event: E,
8}
9
10impl<E: Event> Command for SendEvent<E> {
11    fn apply(self, world: &mut World) {
12        let mut events = world.resource_mut::<Events<E>>();
13        events.send(self.event);
14    }
15}