From 01066718b0f13846587d26b1869f03e3713082c6 Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 12 Mar 2024 20:54:42 +0100 Subject: feat(ecs): make components internally mutable --- ecs/examples/multiple_queries.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ecs/examples') diff --git a/ecs/examples/multiple_queries.rs b/ecs/examples/multiple_queries.rs index ed02a69..e914cc6 100644 --- a/ecs/examples/multiple_queries.rs +++ b/ecs/examples/multiple_queries.rs @@ -32,18 +32,18 @@ impl Display for EnemyName fn do_attacks( attacker_query: Query<(AttackStrength,)>, - mut enemy_query: Query<(Health, EnemyName)>, + enemy_query: Query<(Health, EnemyName)>, ) { for (attack_strength,) in &attacker_query { - for (health, enemy_name) in enemy_query.iter_mut() { - let damage = match attack_strength { + for (mut health, enemy_name) in &enemy_query { + let damage = match *attack_strength { AttackStrength::Strong => 20, AttackStrength::Weak => 10, }; if health.health <= damage { - println!("Enemy '{enemy_name}' died"); + println!("Enemy '{}' died", *enemy_name); health.health = 0; @@ -52,7 +52,7 @@ fn do_attacks( health.health -= damage; - println!("Enemy '{enemy_name}' took {damage} damage"); + println!("Enemy '{}' took {damage} damage", *enemy_name); } } } -- cgit v1.2.3-18-g5258