46 lines
1.3 KiB
GDScript
46 lines
1.3 KiB
GDScript
class_name ActiveWorldAdapter
|
|
extends Node
|
|
|
|
@export var guard_marker: Marker3D
|
|
@export var study_marker: Marker3D
|
|
@export var rest_marker: Marker3D
|
|
@export var pantry_storage: StorageNode
|
|
|
|
|
|
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:
|
|
return _get_storage_target(pantry_storage)
|
|
SimulationIds.ACTION_DEPOSIT_FOOD, SimulationIds.ACTION_WITHDRAW_FOOD:
|
|
return _get_storage_target(pantry_storage)
|
|
if marker == null:
|
|
return {}
|
|
return {"target_id": "", "position": marker.global_position}
|
|
|
|
|
|
func _get_storage_target(storage_node: StorageNode) -> Dictionary:
|
|
if storage_node == null:
|
|
return {}
|
|
return {
|
|
"target_id": String(storage_node.storage_id),
|
|
"position": storage_node.get_interaction_position()
|
|
}
|