-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Duplicated components are not detected using Added query #1443
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior
Description
Bevy version
0.4.0
Operating system & version
macOS 11.2.1
What you did
use bevy::prelude::*;
struct Bananas {
bananas: String
}
fn init(commands: &mut Commands) {
commands.spawn((Bananas { bananas: String::from("🍌") }, ));
commands.spawn((Bananas { bananas: String::from("this banana is overwritten") }, ))
.with(Bananas { bananas: String::from("this banana isn't change detected") });
}
fn changed_bananas(query: Query<&Bananas, Added<Bananas>>) {
for bananas in query.iter() {
info!("added query banana: {}", bananas.bananas);
}
}
fn all_bananas(query: Query<&Bananas>) {
for bananas in query.iter() {
info!("normal query banana: {}", bananas.bananas);
}
}
#[bevy_main]
fn main() {
App::build()
.add_plugin(bevy::log::LogPlugin)
.add_startup_system(init.system())
.add_system(changed_bananas.system())
.add_system(all_bananas.system())
.run();
}What you expected to happen
The following output should be produced
normal query banana: 🍌
added query banana: 🍌
normal query banana: this banana isn't change detected
added query banana: this banana isn't change detected
What actually happened
normal query banana: 🍌
added query banana: 🍌
normal query banana: this banana isn't change detected
Additional information
Adding a duplicated component using spawn().with() produces this behaviour.
So does adding a duplicated component using spawn().insert_one().
Adding a duplicated component using spawn((Banana {}, Banana{})) throws an error.
Possibly related issue: #333
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