namespace ftt.Gameplay.AI
{
    /* [Node documentation]
     * 
     * [Must know]
     *  EnemyNodeData compatible.
     */
    public class ParallelExecutor : INode
    {
        MinotaurNodeData nodeData;
        INode[] parallelExecutionNodes;

        public ParallelExecutor(MinotaurNodeData nodeData, INode[] parallelExecutionNodes)
        {
            this.nodeData = nodeData;
            this.parallelExecutionNodes = parallelExecutionNodes;
        }

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

        /// <summary>
        /// Call to check if the agent is in the currently set waypoint (through his nodeData).
        /// <para>If true, returns false.</para>
        /// <para>If false, call the Run method of the navTo (PatrolNavigateTo INode) and return its return value.</para>
        /// </summary>
        /// <returns></returns>
        public bool Run()
        {
            bool currentRun = false;

            foreach (INode node in parallelExecutionNodes)
            {
                currentRun = node.Run();
            }

            return currentRun;
        }
    }
}