fix pathfinding

This commit is contained in:
2026-03-19 21:35:26 +00:00
parent a97e2908ed
commit a0eb608d73
+6 -4
View File
@@ -155,9 +155,10 @@ struct PathNode {
impl Ord for PathNode { impl Ord for PathNode {
fn cmp(&self, other: &Self) -> std::cmp::Ordering { fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.f_score other
.cmp(&other.f_score) .f_score
.then_with(|| self.g_score.cmp(&other.g_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. /// Returns 100 (default) if tile not found.
#[inline] #[inline]
fn get_tile_weight(tilemap: &TileMap, pos: IVec3) -> u8 { 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. /// Calculate movement cost including tile weight.