summaryrefslogtreecommitdiff
path: root/ecs/examples/multiple_queries.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-03-12 20:54:42 +0100
committerHampusM <hampus@hampusmat.com>2024-03-12 20:54:42 +0100
commit01066718b0f13846587d26b1869f03e3713082c6 (patch)
tree0ef39b49b26330ab1ed2526105a15c7a0cba7c85 /ecs/examples/multiple_queries.rs
parent251beb34720d2e7d60ceaddc811a65f52f15bdbd (diff)
feat(ecs): make components internally mutable
Diffstat (limited to 'ecs/examples/multiple_queries.rs')
-rw-r--r--ecs/examples/multiple_queries.rs10
1 files changed, 5 insertions, 5 deletions
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);
}
}
}