From 99ea5727ca4638efd2979218a128e56c0ce32c44 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 29 Feb 2024 19:57:59 +0100 Subject: feat(ecs): add iterating over queries non-mutably --- ecs/examples/multiple_queries.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ecs/examples/multiple_queries.rs') diff --git a/ecs/examples/multiple_queries.rs b/ecs/examples/multiple_queries.rs index 4f4198a..9a699c2 100644 --- a/ecs/examples/multiple_queries.rs +++ b/ecs/examples/multiple_queries.rs @@ -29,12 +29,12 @@ impl Display for EnemyName } } -fn say_hello( - mut query: Query<(AttackStrength,)>, +fn do_attacks( + attacker_query: Query<(AttackStrength,)>, mut enemy_query: Query<(Health, EnemyName)>, ) { - for (attack_strength,) in query.iter_mut() { + for (attack_strength,) in &attacker_query { for (health, enemy_name) in enemy_query.iter_mut() { let damage = match attack_strength { AttackStrength::Strong => 20, @@ -66,7 +66,7 @@ fn main() { let mut world = World::::new(); - world.register_system(Event::Start, say_hello); + world.register_system(Event::Start, do_attacks); world.create_entity(( Health { health: 100 }, -- cgit v1.2.3-18-g5258