fix
This commit is contained in:
@@ -283,13 +283,21 @@ pub fn demo_system(
|
||||
let idle_dorfs: SmallVec<[Entity; 8]> =
|
||||
idle_dorfs.into_iter().map(|(e, _)| e).collect();
|
||||
|
||||
// Track destinations reserved this tick to avoid assigning the same tile
|
||||
// to multiple dorfs before any have physically dropped their cargo.
|
||||
let mut reserved: SmallVec<[IVec3; 8]> = SmallVec::new();
|
||||
|
||||
for dorf_entity in idle_dorfs {
|
||||
// Compute haul destination fresh for each assignment —
|
||||
// as logs accumulate near origin, each new assignment correctly
|
||||
// finds the next free tile.
|
||||
// Compute haul destination fresh for each assignment,
|
||||
// excluding tiles already reserved this tick.
|
||||
let dest = tilemap
|
||||
.find_nearest_free_cargo_tile(IVec3::ZERO, HAUL_DEST_SEARCH_RADIUS)
|
||||
.find_nearest_free_cargo_tile(
|
||||
IVec3::ZERO,
|
||||
HAUL_DEST_SEARCH_RADIUS,
|
||||
&reserved,
|
||||
)
|
||||
.unwrap_or(IVec3::ZERO);
|
||||
reserved.push(dest);
|
||||
|
||||
let Some((log_entity, log_pos)) = unassigned.pop_front() else {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user