From de8212b5ed78dd26904fd4f7ffa4a343f03acd7a Mon Sep 17 00:00:00 2001 From: Nathan Fenner Date: Tue, 4 Mar 2025 14:19:37 -0800 Subject: [PATCH] update include_entity doc with better example --- crates/bevy_ecs/src/query/iter.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/bevy_ecs/src/query/iter.rs b/crates/bevy_ecs/src/query/iter.rs index cf4b227338..1ee24b6fc9 100644 --- a/crates/bevy_ecs/src/query/iter.rs +++ b/crates/bevy_ecs/src/query/iter.rs @@ -888,11 +888,16 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryIter<'w, 's, D, F> { /// #[derive(Component)] /// struct Damage(f32); /// - /// fn example_system(mut query: Query<(&mut Health, &Damage)>) { - /// for (entity, (mut health, damage)) in query.iter_mut().include_entity() { - /// if damage.0 > 0.0 { - /// health.0 -= damage.0; - /// println!("entity {:?} took damage", entity); + /// fn apply_damage_system(mut query: Query<(&mut Health, &Damage)>) { + /// // Iterate over the input query: + /// for (mut health, damage) in query.iter_mut() { + /// health.0 -= damage.0; + /// } + /// + /// // Iterate again, this time including the entity: + /// for (entity, (health, damage)) in query.iter().include_entity() { + /// if health.0 <= 0.0 { + /// println!("entity {:?} has been reduce to 0 health by {} damage", entity, damage.0); /// } /// } /// }