From a0eb608d73e4e37b3c5fb4940d1de116b3cecfe8 Mon Sep 17 00:00:00 2001 From: popertots Date: Thu, 19 Mar 2026 21:35:26 +0000 Subject: [PATCH] fix pathfinding --- src/entities/shared_systems/pathfinding.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/entities/shared_systems/pathfinding.rs b/src/entities/shared_systems/pathfinding.rs index ed355bb..da87f18 100644 --- a/src/entities/shared_systems/pathfinding.rs +++ b/src/entities/shared_systems/pathfinding.rs @@ -155,9 +155,10 @@ struct PathNode { impl Ord for PathNode { fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.f_score - .cmp(&other.f_score) - .then_with(|| self.g_score.cmp(&other.g_score)) + other + .f_score + .cmp(&self.f_score) + .then_with(|| other.g_score.cmp(&self.g_score)) } } @@ -559,7 +560,8 @@ fn is_standable_tile(tilemap: &TileMap, pos: IVec3) -> bool { /// Returns 100 (default) if tile not found. #[inline] fn get_tile_weight(tilemap: &TileMap, pos: IVec3) -> u8 { - tilemap.get_astar_weight(pos) + let floor_pos = IVec3::new(pos.x, pos.y, pos.z - ITILE_SIZE); + tilemap.get_astar_weight(floor_pos) } /// Calculate movement cost including tile weight.