diff options
author | HampusM <hampus@hampusmat.com> | 2024-02-29 19:57:59 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-02-29 19:58:10 +0100 |
commit | 99ea5727ca4638efd2979218a128e56c0ce32c44 (patch) | |
tree | f167d9d88ad8b4cfe7089df3cc67e1be9b0f9a06 /ecs/examples/multiple_queries.rs | |
parent | bd627c91819ea98e551b29027de6eaaccbe45ed6 (diff) |
feat(ecs): add iterating over queries non-mutably
Diffstat (limited to 'ecs/examples/multiple_queries.rs')
-rw-r--r-- | ecs/examples/multiple_queries.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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::<Event>::new(); - world.register_system(Event::Start, say_hello); + world.register_system(Event::Start, do_attacks); world.create_entity(( Health { health: 100 }, |