fix(server): prioritize stockpile dropoff over wandering after gathering
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user