using System.Collections.Generic;
using UnityEngine;

namespace ftt.Gameplay.AI
{
    /* [Node Documentation]
     * 
     * [Custom Selector]
     *  Used to change between Idle and Patrolling AI behaviour.
     */
    public class IdlePatrolChaseActivator : INode
    {
        MinotaurNodeData nodeData;
        BehaviourTree patrol;
        BehaviourTree chase;

        public IdlePatrolChaseActivator(MinotaurNodeData nodeData, BehaviourTree patrol, BehaviourTree chase)
        {
            this.nodeData = nodeData;

            this.patrol = patrol;
            this.chase = chase;
        }

        /// <summary>
        /// Call to get the node data passed in the creation of the node.
        /// </summary>
        public MinotaurNodeData GetNodeData()
        {
            return nodeData;
        }

        /// <summary>
        /// Call to update the first branch that returns true from the passed list of INode children.
        /// </summary>
        public bool Run()
        {
            if (!nodeData.GetTargetFound)
            {
                return patrol.Run();
            }
            else
            {
                return chase.Run();
            }
        }
    }
}
