diff --git a/server/src/systems/gatheringSystem.ts b/server/src/systems/gatheringSystem.ts index 0e24541..ba26717 100644 --- a/server/src/systems/gatheringSystem.ts +++ b/server/src/systems/gatheringSystem.ts @@ -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(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(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; }