fix
This commit is contained in:
@@ -146,25 +146,32 @@ pub fn task_executor_system(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ambulatory.target.is_none() {
|
if ambulatory.target.is_none() {
|
||||||
// Find the actual ground level at the trunk's XY for pathfinding.
|
// Find the actual walkable surface above the floor at the trunk's XY.
|
||||||
// Walking to the trunk itself (z + 1.0) may land on an unreachable tile.
|
// Scan for a floor tile, then return the z of the tile above it + 1.0
|
||||||
// Instead, find a standable tile at the trunk's XY location.
|
// (same pattern as spawn_log_cargo's find_surface_at).
|
||||||
let ground_z = (0..=4i32)
|
use crate::constants::ITILE_SIZE;
|
||||||
.map(|z| {
|
let target_z = (-3i32..=4i32)
|
||||||
IVec3::new(
|
.find_map(|z| {
|
||||||
trunk_pos.x,
|
let floor_pos =
|
||||||
trunk_pos.y,
|
IVec3::new(trunk_pos.x, trunk_pos.y, z * ITILE_SIZE);
|
||||||
z * crate::constants::ITILE_SIZE,
|
if tilemap_mut.floor_tiles.contains_key(&floor_pos) {
|
||||||
)
|
let above = IVec3::new(
|
||||||
|
trunk_pos.x,
|
||||||
|
trunk_pos.y,
|
||||||
|
floor_pos.z + ITILE_SIZE,
|
||||||
|
);
|
||||||
|
if tilemap_mut.is_standable(above) {
|
||||||
|
return Some(above.z as f32 + 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
})
|
})
|
||||||
.find(|&pos| tilemap_mut.is_standable(pos))
|
|
||||||
.map(|pos| pos.z as f32 + 1.0)
|
|
||||||
.unwrap_or(trunk_pos.z as f32 + 1.0);
|
.unwrap_or(trunk_pos.z as f32 + 1.0);
|
||||||
|
|
||||||
ambulatory.target = Some(Vec3::new(
|
ambulatory.target = Some(Vec3::new(
|
||||||
trunk_pos.x as f32,
|
trunk_pos.x as f32,
|
||||||
trunk_pos.y as f32,
|
trunk_pos.y as f32,
|
||||||
ground_z,
|
target_z,
|
||||||
));
|
));
|
||||||
ambulatory.current_path = None;
|
ambulatory.current_path = None;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user