class_name SimulationEventRecorder extends RefCounted const SimulationEventLogScript := preload("res://simulation/events/SimulationEventLog.gd") var event_log: RefCounted var npcs: Array[SimNPC] = [] var tick_provider: Callable func configure(log: RefCounted, tick_source: Callable) -> void: event_log = log tick_provider = tick_source func set_npcs(npc_list: Array[SimNPC]) -> void: npcs = npc_list func record_economic( event_type: StringName, actor_id: int, source_id: StringName, destination_id: StringName, item_id: StringName, amount: float ) -> void: record_economic_at( event_type, actor_id, source_id, destination_id, item_id, amount, get_event_world_position(actor_id, source_id, destination_id) ) func record_economic_at( event_type: StringName, actor_id: int, source_id: StringName, destination_id: StringName, item_id: StringName, amount: float, world_position: Vector3 ) -> void: event_log.record_economic( tick_provider.call(), event_type, actor_id, source_id, destination_id, item_id, amount, world_position ) func record_narrative( event_type: StringName, actor_id: int, source_id: StringName = &"", action_display: String = "", action_id: StringName = &"", item_id: StringName = &"", required_amount: float = 0.0 ) -> void: record_narrative_at( event_type, actor_id, source_id, action_display, get_event_world_position(actor_id, source_id, &""), action_id, item_id, required_amount ) func record_narrative_at( event_type: StringName, actor_id: int, source_id: StringName, action_display: String, world_position: Vector3, action_id: StringName = &"", item_id: StringName = &"", required_amount: float = 0.0 ) -> void: event_log.record_narrative( tick_provider.call(), event_type, actor_id, source_id, action_display, world_position, action_id, item_id, required_amount ) func get_event_world_position( actor_id: int, source_id: StringName, destination_id: StringName ) -> Vector3: for npc in npcs: if npc.id != actor_id: continue if not npc.target_id.is_empty() and npc.target_id in [source_id, destination_id]: return npc.travel_target_position return npc.position return Vector3.ZERO