-
-
Notifications
You must be signed in to change notification settings - Fork 4.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.14.0-rc.2
Reproduction Example
use bevy::core::{FrameCount, FrameCountPlugin};
use bevy::prelude::*;
#[derive(Component)]
struct Foo;
fn main() {
let mut app = App::new();
app.add_plugins(FrameCountPlugin);
app.add_systems(Startup, |mut commands: Commands| {
for _ in 0..100 {
commands.spawn(Foo);
}
});
app.add_systems(First, |counter: Res<FrameCount>| {
println!("Frame {}:", counter.0)
});
fn detector_system(mut removals: RemovedComponents<Foo>, foos: Query<Entity, With<Foo>>) {
for e in removals.read() {
println!(" Detected removed Foo component for {e:?}")
}
println!(" Total Foos: {}", foos.iter().count())
}
fn deleter_system(foos: Query<Entity, With<Foo>>, mut commands: Commands) {
foos.iter().next().map(|e| {
commands.entity(e).remove::<Foo>();
});
}
app.add_systems(Update, (detector_system, deleter_system).chain());
app.update();
app.update();
app.update();
app.update();
}
Output when using bevy 0.13.2
Frame 0:
Total Foos: 100
Frame 1:
Detected removed Foo component for 0v1
Total Foos: 99
Frame 2:
Detected removed Foo component for 99v1
Total Foos: 98
Frame 3:
Detected removed Foo component for 98v1
Total Foos: 97
Output when using bevy `0.14.0-rc.2
Frame 0:
Total Foos: 100
Frame 1:
Total Foos: 99
Frame 2:
Total Foos: 98
Frame 3:
Total Foos: 97
Additional information
Swapping the order of detector_system and deleter_system results in the events showing up as expected.
Replacing remove::<Foo> with .despawn() does not change the outcome.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior