feat: add structured economic events
This commit is contained in:
@@ -33,6 +33,14 @@ func initialize_world_view() -> void:
|
||||
simulation_manager.npc_died.connect(_on_npc_died)
|
||||
else:
|
||||
push_error("WorldViewManager: SimulationManager has no npc_died signal")
|
||||
if simulation_manager.has_signal("npc_inventory_changed"):
|
||||
simulation_manager.npc_inventory_changed.connect(
|
||||
_on_npc_inventory_changed
|
||||
)
|
||||
else:
|
||||
push_error(
|
||||
"WorldViewManager: SimulationManager has no npc_inventory_changed signal"
|
||||
)
|
||||
spawn_initial_npcs()
|
||||
|
||||
func spawn_initial_npcs() -> void:
|
||||
@@ -155,3 +163,20 @@ func _on_npc_died(npc: SimNPC) -> void:
|
||||
visual.apply_dead_visual_state()
|
||||
else:
|
||||
push_error("WorldViewManager: NPCVisual has no apply_dead_visual_state")
|
||||
|
||||
func _on_npc_inventory_changed(
|
||||
npc: SimNPC,
|
||||
item_id: StringName,
|
||||
amount: float
|
||||
) -> void:
|
||||
if item_id != SimulationIds.RESOURCE_FOOD:
|
||||
return
|
||||
var visual = active_npc_visuals.get(npc.id)
|
||||
if visual == null:
|
||||
return
|
||||
if visual.has_method("set_carried_food_visible"):
|
||||
visual.set_carried_food_visible(amount > 0.0)
|
||||
else:
|
||||
push_error(
|
||||
"WorldViewManager: NPCVisual has no set_carried_food_visible method"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user