Fix: Set ambulatory.target for HaulCargo when approach pre-computed

When job_pathfinding pre-computes the approach tile for HaulCargo,
the executor was skipping target assignment because:
1. approach.is_none() was false (approach already set)
2. ambulatory.target.is_none() was true (no target set)
3. No else branch to set the target

Added else-if branch to set target when approach is set but target isn't.
This fixes dorfs freezing in MovingToCargo state with target=None.
This commit is contained in:
2026-04-04 12:16:23 +01:00
parent 022e21d484
commit 8e3e8b8b8c
+17 -1
View File
@@ -499,10 +499,25 @@ pub fn task_executor_system(
continue; continue;
} }
} }
} else if ambulatory.target.is_none() {
// Have approach but no target — set target and start pathfinding
if let Some(approach_tile) = *approach {
info!(
"[HAUL] {:?} setting target to approach {:?}",
entity, approach_tile
);
ambulatory.target = Some(Vec3::new(
approach_tile.x as f32,
approach_tile.y as f32,
approach_tile.z as f32 + 1.0,
));
ambulatory.current_path = None;
}
} }
// Check arrival at cargo tile // Check arrival at cargo tile (only when target is set)
// Use approach tile position for distance check, not target None // Use approach tile position for distance check, not target None
if ambulatory.target.is_some() {
if let Some(approach_tile) = *approach { if let Some(approach_tile) = *approach {
let dx = transform.translation.x - approach_tile.x as f32; let dx = transform.translation.x - approach_tile.x as f32;
let dy = transform.translation.y - approach_tile.y as f32; let dy = transform.translation.y - approach_tile.y as f32;
@@ -520,6 +535,7 @@ pub fn task_executor_system(
} }
} }
} }
}
HaulStep::PickingUp => { HaulStep::PickingUp => {
info!("[HAUL] {:?} PickingUp: cargo_pos={:?}", entity, cargo_pos); info!("[HAUL] {:?} PickingUp: cargo_pos={:?}", entity, cargo_pos);
if haul.is_occupied() { if haul.is_occupied() {