feat: add behaviour events from the simulation results

This commit is contained in:
Rijad Zuzo
2026-06-19 10:42:11 +02:00
parent af3495f4e3
commit c37eb9bd3d
4 changed files with 63 additions and 26 deletions
+24 -9
View File
@@ -20,16 +20,18 @@ func debug_log(message: String) -> void:
print("[WorldViewManager] ", message)
func _ready() -> void:
call_deferred("spawn_initial_npcs")
call_deferred("initialize_world_view")
var target_update_timer := 0.0
var target_update_interval := 0.5
func _process(delta: float) -> void:
target_update_timer += delta
if target_update_timer >= target_update_interval:
target_update_timer = 0.0
update_npc_targets()
func initialize_world_view() -> void:
await get_tree().physics_frame
spawn_initial_npcs()
if simulation_manager.has_signal("npc_task_changed"):
simulation_manager.npc_task_changed.connect(_on_npc_task_changed)
else:
push_error("WorldViewManager: SimulationManager has no npc_task_changed signal")
update_npc_targets()
func spawn_initial_npcs() -> void:
if simulation_manager == null:
@@ -96,3 +98,16 @@ func get_target_for_task(task: String) -> Marker3D:
return food_zone
_:
return rest_zone
func _on_npc_task_changed(npc: SimNPC, old_task: String, new_task: String) -> void:
if DEBUG_LOGS:
debug_log("%s changed task: %s -> %s" % [npc.npc_name, old_task, new_task])
if not active_npc_visuals.has(npc.id):
return
var visual = active_npc_visuals[npc.id]
var target := get_target_for_task(new_task)
if target != null:
visual.set_target_position(target.global_position)