feat: add location-based food storage loop

This commit is contained in:
2026-07-05 17:57:24 +02:00
parent 3ea8f02d55
commit 6dbb395bd6
22 changed files with 469 additions and 72 deletions
+11 -2
View File
@@ -5,13 +5,22 @@ func select_action(npc: SimNPC, village: SimVillage) -> ActionSelectionResult:
if npc.is_dead:
return null
if npc.is_starving:
if village.food > 0:
if npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) >= 1.0:
return ActionSelectionResult.new(SimulationIds.ACTION_EAT, 1.0)
if village.food > 0:
return ActionSelectionResult.new(
SimulationIds.ACTION_WITHDRAW_FOOD,
1.0
)
return ActionSelectionResult.new(SimulationIds.ACTION_GATHER_FOOD, 4.0)
if npc.hunger > 75.0:
if village.food > 0:
if npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) >= 1.0:
return ActionSelectionResult.new(SimulationIds.ACTION_EAT)
if village.food > 0:
return ActionSelectionResult.new(SimulationIds.ACTION_WITHDRAW_FOOD)
return ActionSelectionResult.new(SimulationIds.ACTION_GATHER_FOOD)
if npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) > 0.0:
return ActionSelectionResult.new(SimulationIds.ACTION_DEPOSIT_FOOD)
if npc.energy < 25.0:
return ActionSelectionResult.new(SimulationIds.ACTION_REST)
return ActionSelectionResult.new(_choose_best_work_action(npc, village))