Mutable query

This commit is contained in:
Greg Shuflin 2025-01-08 02:02:47 -08:00
parent 932866a943
commit 74502b368c

View File

@ -24,9 +24,19 @@ fn greet_people(query: Query<&Name, With<Person>>) {
}
}
fn update_people(mut query: Query<&mut Name, With<Person>>) {
for mut name in &mut query {
if name.0 == "Orlando Tampa" {
name.0 = "Carlos Satanick".to_string();
}
break;
}
}
fn main() {
App::new()
.add_systems(Startup, add_people)
.add_systems(Update, (gamarjoba, greet_people))
.add_systems(Update, (gamarjoba, (update_people, greet_people).chain()))
.run();
}