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.
This commit is contained in:
WiseDev 2026-08-23 14:16:38 +03:00
parent 8a4a81057b
commit 64a457545d

View file

@ -165,6 +165,13 @@ impl LogicGameObjectEntry {
} }
} }
} }
struct CollisionBody {
alive: bool,
position: (i32, i32),
stats: LogicCharacterStats,
owner: i32,
moves: bool,
}
impl LogicBattle { impl LogicBattle {
fn regenerate_mana(&mut self, tick: i32) { fn regenerate_mana(&mut self, tick: i32) {
let max_mana = crate::LogicGlobals::number(GLOBAL_MAX_MANA).max(1); let max_mana = crate::LogicGlobals::number(GLOBAL_MAX_MANA).max(1);
@ -366,36 +373,39 @@ impl LogicBattle {
} }
} }
fn resolve_collisions(&mut self) { fn resolve_collisions(&mut self) {
let bodies: Vec<(bool, (i32, i32), LogicCharacterStats, i32, bool)> = self let bodies: Vec<CollisionBody> = self
.objects .objects
.objects .objects
.iter() .iter()
.map(|entry| { .map(|entry| CollisionBody {
( alive: entry.is_alive(),
entry.is_alive(), position: entry.position(),
entry.position(), stats: entry.stats(),
entry.stats(), owner: entry.owner_index(),
entry.owner_index(), moves: entry.movement().is_some(),
entry.movement().is_some(),
)
}) })
.collect(); .collect();
for index in 0..self.objects.objects.len() { 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 { if !alive || !moves || stats.collision_radius < 1 {
continue; continue;
} }
let mut push = (0i64, 0i64, 0i32); let mut push = (0i64, 0i64, 0i32);
for (other, (other_alive, theirs, other_stats, _, other_moves)) in for (other, body) in bodies.iter().enumerate() {
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 {
if other == index || !other_alive || other_stats.collision_radius < 1 {
continue; continue;
} }
if stats.flying != other_stats.flying { if stats.flying != other_stats.flying {
continue; continue;
} }
let reach = if *other_moves { let reach = if other_moves {
stats.collision_radius stats.collision_radius
} else { } else {
stats.collision_radius.min(COLLISION_RADIUS_CAP) stats.collision_radius.min(COLLISION_RADIUS_CAP)