Skip to content

Commit 303d6dc

Browse files
Clear componentized Events too
1 parent fb69645 commit 303d6dc

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

crates/bevy_ecs/src/event.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate as bevy_ecs;
22
use crate::{
33
component::Component,
4-
system::{Local, Res, ResMut, SystemParam},
4+
system::{Local, Query, Res, ResMut, SystemParam},
55
};
66
use bevy_utils::tracing::trace;
77
use std::{
@@ -323,9 +323,16 @@ impl<T: Component> Events<T> {
323323
}
324324
}
325325

326-
/// A system that calls [Events::update] once per frame.
327-
pub fn update_system(mut events: ResMut<Self>) {
328-
events.update();
326+
/// A system that calls [Events::update] once per frame on all events of the specified type.
327+
///
328+
/// This clears all events from the previous frame,
329+
/// and advances the current frame's buffer so it is ready to be cleared.
330+
pub fn update_system(
331+
mut resource_events: ResMut<Self>,
332+
mut component_events: Query<&mut Self>,
333+
) {
334+
resource_events.update();
335+
component_events.for_each_mut(|mut e| e.update());
329336
}
330337

331338
/// Removes all events.

0 commit comments

Comments
 (0)