feat: authoritative extraction from ResourceNode on task completion
Phase 3 of ResourceNode migration: - Add apply_resource_delta to SimVillage for clean resource changes - Extract from reserved ResourceNode on task completion instead of hard-coded apply_npc_task for gather_food/gather_wood - Detect depleted/unavailable targets on arrival and replan
This commit is contained in:
@@ -69,6 +69,25 @@ func update_priorities() -> void:
|
||||
if DEBUG_LOGS:
|
||||
print(get_priority_summary())
|
||||
|
||||
func apply_resource_delta(resource_id: StringName, amount: float) -> void:
|
||||
match resource_id:
|
||||
&"food":
|
||||
food += amount
|
||||
&"wood":
|
||||
wood += amount
|
||||
&"safety":
|
||||
safety = clamp(safety + amount, 0.0, 100.0)
|
||||
&"knowledge":
|
||||
knowledge += amount
|
||||
|
||||
food = max(food, 0.0)
|
||||
wood = max(wood, 0.0)
|
||||
safety = clamp(safety, 0.0, 100.0)
|
||||
knowledge = max(knowledge, 0.0)
|
||||
|
||||
update_modifiers()
|
||||
update_priorities()
|
||||
|
||||
func apply_npc_task(npc: SimNPC) -> void:
|
||||
if npc.is_dead:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user