extends BeehaveTree

func _ready():
	if Engine.is_editor_hint():
		return
		
	# Get parent node safely
	var parent = get_parent()
	if not parent:
		push_error("BehaviorTree: No parent node found")
		return
		
	# Only setup for bots
	if not parent.is_in_group("Bots"):
		queue_free()  # Remove tree if not a bot
		return
	
	# Set this tree's actor
	actor = parent
	
	enabled = parent.is_multiplayer_authority() and parent.is_bot
	
	# Set up blackboard with initial values
	if blackboard:
		blackboard.set_value("action_points", parent.action_points)
		blackboard.set_value("current_action", "idle")
		blackboard.set_value("grab_position", parent.current_position)  # Default grab position
		blackboard.set_value("move_target", null)
