fix pathfinding
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user