fix(server): prioritize stockpile dropoff over wandering after gathering

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-03-09 03:00:55 +00:00
parent 067976f9a2
commit 9a3e9d4757
+13 -16
View File
@@ -38,24 +38,21 @@ export function gatheringSystem(world: World, map: GameMap): void {
}
world.removeComponent(entity, 'gatheringState');
// Decide next action
if (needs.productivity >= PRODUCTIVITY_THRESHOLD) {
brain.currentGoal = 'wander';
} else {
// Check if a stockpile exists for drop-off
let hasStockpile = false;
for (const sEntity of world.query('structure')) {
const sData = world.getComponent<StructureData>(sEntity, 'structure');
if (sData && sData.type === 'stockpile' && sData.buildProgress === undefined) {
hasStockpile = true;
break;
}
// Decide next action: always drop off first if possible
let hasStockpile = false;
for (const sEntity of world.query('structure')) {
const sData = world.getComponent<StructureData>(sEntity, 'structure');
if (sData && sData.type === 'stockpile' && sData.buildProgress === undefined) {
hasStockpile = true;
break;
}
if (hasStockpile && inv && inv.size > 0) {
brain.currentGoal = 'dropoff';
}
// else brain stays on 'gather', npcBrain will pick new target next tick
}
if (hasStockpile && inv && inv.size > 0) {
brain.currentGoal = 'dropoff';
} else if (needs.productivity >= PRODUCTIVITY_THRESHOLD) {
brain.currentGoal = 'wander';
}
// else brain stays on 'gather', npcBrain will pick new target next tick
}
continue;
}