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 {
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<CollisionBody> = 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)