/// <summary>
        /// Ticks the iterator.
        /// </summary>
        public void Update()
        {
            CallOnEnterOnQueuedNodes();
            TickBranch();

            int           index = _traversal.Peek();
            BehaviourNode node  = _tree.allNodes[index];

            LastStatusReturned = node.Run();

#if UNITY_EDITOR
            node.SetStatusEditor(LastStatusReturned);
#endif

            if (LastStatusReturned != BehaviourNode.Status.Running)
            {
                PopNode();
                CallOnChildExit(node);
            }

            if (_traversal.Count == 0)
            {
                OnDone();
            }
        }
Example #2
0
        /// <summary>
        /// Ticks the iterator.
        /// </summary>
        public void Update()
        {
            CallOnEnterOnQueuedNodes();
            int           index = traversal.Peek();
            BehaviourNode node  = tree.Nodes[index];

            BehaviourNode.Status s = node.Run();

            LastExecutedStatus = s;

#if UNITY_EDITOR
            node.StatusEditorResult = (BehaviourNode.StatusEditor)s;
#endif

            if (s != BehaviourNode.Status.Running)
            {
                PopNode();
                OnChildExit(node, s);
            }

            if (traversal.Count == 0)
            {
                OnDone();
            }
        }