class_name ActiveWorldAdapter
extends Node

@export var guard_marker: Marker3D
@export var study_marker: Marker3D
@export var rest_marker: Marker3D
@export var pantry_marker: Marker3D


func get_resource_candidates(action_id: StringName) -> Array[Dictionary]:
	var candidates: Array[Dictionary] = []
	for node in ResourceNode.get_all():
		if node.action_id != action_id or node.interaction_point == null:
			continue
		candidates.append(
			{"target_id": String(node.node_id), "position": node.interaction_point.global_position}
		)
	return candidates


func get_activity_target(action_id: StringName) -> Dictionary:
	var marker: Marker3D
	match action_id:
		SimulationIds.ACTION_PATROL:
			marker = guard_marker
		SimulationIds.ACTION_STUDY:
			marker = study_marker
		SimulationIds.ACTION_REST:
			marker = rest_marker
		SimulationIds.ACTION_EAT:
			marker = pantry_marker
		SimulationIds.ACTION_DEPOSIT_FOOD, SimulationIds.ACTION_WITHDRAW_FOOD:
			marker = pantry_marker
	if marker == null:
		return {}
	var target_id := ""
	if (
		action_id
		in [
			SimulationIds.ACTION_EAT,
			SimulationIds.ACTION_DEPOSIT_FOOD,
			SimulationIds.ACTION_WITHDRAW_FOOD
		]
	):
		target_id = String(SimulationIds.STORAGE_VILLAGE_PANTRY)
	return {"target_id": target_id, "position": marker.global_position}
