コード例 #1
0
        public override Status Run()
        {
            if (IsAnyChildWithStatus(Status.Failure))
            {
                return(Status.Failure);
            }

            if (AreAllChildrenWithStatus(Status.Success))
            {
                return(Status.Success);
            }

            // Process the sub-iterators.
            for (int i = 0; i < subIterators.Count; ++i)
            {
                // Keep updating the iterators that are not done.
                BehaviourIterator itr = subIterators[i];
                if (itr.IsRunning)
                {
                    itr.Update();
                }
            }

            // Parallel iterators still running.
            return(Status.Running);
        }
コード例 #2
0
        public override Status Run()
        {
            // All iterators done.
            // Since there was no success interruption, that means
            // all iterators returned failure, so the parallel node
            // returns failure aswell.
            if (IsDone)
            {
                return(Status.Failure);
            }

            // Process the sub-iterators.
            for (int i = 0; i < _subIterators.Count; ++i)
            {
                BehaviourIterator itr = _subIterators[i];

                // Keep updating the iterators that are not done.
                if (itr.IsRunning)
                {
                    itr.Update();
                }

                // Iterator finished, it must have returned Success or Failure.
                // If the iterator returned success, then interrupt the parallel process
                // and have the parallel node return success.
                else if (itr.LastStatusReturned == Status.Success)
                {
                    return(Status.Success);
                }
            }

            // Parallel iterators still running.
            return(Status.Running);
        }