From 64a457545d528b0aa56ef9db9d7b3d595c23ae6c Mon Sep 17 00:00:00 2001 From: WiseDev <83840010+wisedevik@users.noreply.github.com> Date: Sun, 23 Aug 2026 14:16:38 +0300 Subject: [PATCH] name the collision body instead of a five-tuple fixes the previous commit, which named the type but never defined it and did not build. --- crates/logic/src/battle/logic_simulation.rs | 40 +++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/crates/logic/src/battle/logic_simulation.rs b/crates/logic/src/battle/logic_simulation.rs index f394583..fdad36e 100644 --- a/crates/logic/src/battle/logic_simulation.rs +++ b/crates/logic/src/battle/logic_simulation.rs @@ -165,6 +165,13 @@ impl LogicGameObjectEntry { } } } +struct CollisionBody { + alive: bool, + position: (i32, i32), + stats: LogicCharacterStats, + owner: i32, + moves: bool, +} impl LogicBattle { fn regenerate_mana(&mut self, tick: i32) { let max_mana = crate::LogicGlobals::number(GLOBAL_MAX_MANA).max(1); @@ -366,36 +373,39 @@ impl LogicBattle { } } fn resolve_collisions(&mut self) { - let bodies: Vec<(bool, (i32, i32), LogicCharacterStats, i32, bool)> = self + let bodies: Vec = self .objects .objects .iter() - .map(|entry| { - ( - entry.is_alive(), - entry.position(), - entry.stats(), - entry.owner_index(), - entry.movement().is_some(), - ) + .map(|entry| CollisionBody { + alive: entry.is_alive(), + position: entry.position(), + stats: entry.stats(), + owner: entry.owner_index(), + moves: entry.movement().is_some(), }) .collect(); for index in 0..self.objects.objects.len() { - let (alive, mine, stats, owner, moves) = &bodies[index]; + let CollisionBody { + alive, + position: mine, + stats, + owner, + moves, + } = &bodies[index]; if !alive || !moves || stats.collision_radius < 1 { continue; } let mut push = (0i64, 0i64, 0i32); - for (other, (other_alive, theirs, other_stats, _, other_moves)) in - bodies.iter().enumerate() - { - if other == index || !other_alive || other_stats.collision_radius < 1 { + for (other, body) in bodies.iter().enumerate() { + let (theirs, other_stats, other_moves) = (&body.position, &body.stats, body.moves); + if other == index || !body.alive || other_stats.collision_radius < 1 { continue; } if stats.flying != other_stats.flying { continue; } - let reach = if *other_moves { + let reach = if other_moves { stats.collision_radius } else { stats.collision_radius.min(COLLISION_RADIUS_CAP)