feat: wood consumption for patrol and study

Patrol and study now consume 1 wood from the village woodpile on completion, recording an item_consumed economic event. This gives wood a purpose and creates resource pressure between gathering and work-support activities. Familiarity serialization switched from raw Dictionary to sorted Array of {id, score} pairs for deterministic JSON checksum output across save/load.
This commit is contained in:
2026-07-09 00:16:52 +02:00
parent 595d67724f
commit 2c3890502a
2 changed files with 49 additions and 3 deletions
+31 -1
View File
@@ -243,9 +243,20 @@ func simulate_tick() -> void:
print("[SimulationManager] ", npc.npc_name, " completed sleep at home")
elif (
completed_task
not in [SimulationIds.ACTION_GATHER_FOOD, SimulationIds.ACTION_GATHER_WOOD]
not in [
SimulationIds.ACTION_GATHER_FOOD,
SimulationIds.ACTION_GATHER_WOOD,
SimulationIds.ACTION_PATROL,
SimulationIds.ACTION_STUDY
]
):
village.apply_npc_task(npc)
elif completed_task == SimulationIds.ACTION_PATROL:
_consume_wood_for_work(npc, completed_task)
village.apply_npc_task(npc)
elif completed_task == SimulationIds.ACTION_STUDY:
_consume_wood_for_work(npc, completed_task)
village.apply_npc_task(npc)
elif debug_logs:
print(
"[SimulationManager] ",
@@ -631,6 +642,25 @@ func deposit_npc_wood(npc: SimNPC) -> float:
return deposited
func _consume_wood_for_work(npc: SimNPC, action_id: StringName) -> void:
var woodpile := get_woodpile()
if woodpile == null:
return
var consumed := woodpile.withdraw(SimulationIds.RESOURCE_WOOD, 1.0)
_sync_village_wood()
if consumed >= 1.0:
_record_economic_event(
SimulationIds.EVENT_ITEM_CONSUMED,
npc.id,
SimulationIds.STORAGE_VILLAGE_WOODPILE,
&"consumed",
SimulationIds.RESOURCE_WOOD,
consumed
)
if debug_logs:
print("[SimulationManager] %s consumed wood for %s" % [npc.npc_name, action_id])
func withdraw_to_npc(npc: SimNPC, item_id: StringName, amount: float) -> float:
var withdrawn := get_pantry().withdraw(item_id, amount)
npc.add_inventory(item_id, withdrawn)