Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Add helpers to send Events from World #5355

Closed
wants to merge 9 commits into from
13 changes: 13 additions & 0 deletions crates/bevy_ecs/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,19 @@ impl World {
result
}

/// "Sends" an `event`.
aevyrie marked this conversation as resolved.
Show resolved Hide resolved
aevyrie marked this conversation as resolved.
Show resolved Hide resolved
aevyrie marked this conversation as resolved.
Show resolved Hide resolved
#[inline]
pub fn event_send<E: crate::event::Event>(&mut self, event: E) {
self.resource_mut::<crate::event::Events<E>>().send(event);
aevyrie marked this conversation as resolved.
Show resolved Hide resolved
}

/// Sends the default value of the event.
aevyrie marked this conversation as resolved.
Show resolved Hide resolved
aevyrie marked this conversation as resolved.
Show resolved Hide resolved
#[inline]
pub fn event_send_default<E: crate::event::Event + Default>(&mut self) {
self.resource_mut::<crate::event::Events<E>>()
.send_default();
}

/// # Safety
/// `component_id` must be assigned to a component of type `R`
#[inline]
Expand Down