-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior
Milestone
Description
Bevy version 0.12.1
Events are not silently dropped the turn after they're sent but instead accumulate in the EventReader's buffer.
What I did
Here's an example:
use std::cmp::Ordering;
use bevy::prelude::*;
#[derive(Event)]
struct Ev;
fn send(mut evw: EventWriter<Ev>) {
evw.send(Ev);
}
fn read(mut evr: EventReader<Ev>) {
println!("{}", evr.iter().count());
}
// Generates a condition returning true on the nth frame
fn nth_frame(n: u32) -> impl FnMut() -> bool + Clone {
let mut run = 1;
move || match run.cmp(&n) {
Ordering::Greater => false,
Ordering::Equal => {
run += 1;
true
}
Ordering::Less => {
run += 1;
false
}
}
}
fn main() {
App::new()
.add_event::<Ev>()
.add_plugins(DefaultPlugins)
.add_systems(Update, send)
.add_systems(Update, read.after(send).run_if(nth_frame(10)))
.run();
}
What went wrong
Under version 0.11.3, this prints 2 as expected but under 0.12.1 I'm getting 10.
zachbateman, Azorlogh, AlexAegis, CaptainOachkatzl, Inspirateur and 1 more
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior