refactor: move resource authority into simulation
This commit is contained in:
@@ -139,15 +139,18 @@ func _try_get_resource_target(npc: SimNPC, task: String) -> Variant:
|
||||
if visual == null:
|
||||
return null
|
||||
|
||||
var node := ResourceNode.find_available(action_id, npc.id, visual.global_position)
|
||||
if not simulation_manager.has_method("acquire_resource_target"):
|
||||
push_error("WorldViewManager: SimulationManager cannot acquire resources")
|
||||
return null
|
||||
var node: ResourceNode = simulation_manager.acquire_resource_target(
|
||||
action_id,
|
||||
npc.id,
|
||||
visual.global_position
|
||||
)
|
||||
if node == null:
|
||||
debug_log("No available resource node for %s" % task)
|
||||
return null
|
||||
|
||||
if not node.reserve(npc.id):
|
||||
debug_log("Failed to reserve %s for %s" % [node.node_id, npc.npc_name])
|
||||
return null
|
||||
|
||||
npc.target_id = node.node_id
|
||||
debug_log("%s reserved %s for %s" % [npc.npc_name, node.node_id, task])
|
||||
return node.interaction_point.global_position
|
||||
|
||||
Reference in New Issue
Block a user