This commit is contained in:
2026-03-22 15:23:44 +00:00
parent 3b9b2d9c88
commit c46e23af06
4 changed files with 31 additions and 10 deletions
+12 -4
View File
@@ -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;
+2 -2
View File
@@ -276,7 +276,7 @@ pub fn task_executor_system(
if chosen_drop.is_none() {
*chosen_drop = Some(
tilemap_mut
.find_nearest_free_cargo_tile(*dest, 8)
.find_nearest_free_cargo_tile(*dest, 8, &[])
.unwrap_or(*dest),
);
}
@@ -331,7 +331,7 @@ pub fn task_executor_system(
if chosen_drop.is_none() {
*chosen_drop = Some(
tilemap_mut
.find_nearest_free_cargo_tile(*pos, 8)
.find_nearest_free_cargo_tile(*pos, 8, &[])
.unwrap_or(*pos),
);
}