/// <summary> /// Tells the iterator to abort the current running subtree and jump to the aborter. /// </summary> /// <param name="aborter"></param> public void OnAbort(ConditionalAbort aborter) { BehaviourNode parent = aborter.Parent; int terminatingIndex = BehaviourNode.kInvalidOrder; if (parent) { terminatingIndex = parent.preOrderIndex; } // If an abort node is the root, then we need to empty the entire traversal. // We can achieve this by setting the terminating index to the invalid index, which is an invalid index // and will empty the traversal. while (_traversal.Count != 0 && _traversal.Peek() != terminatingIndex) { StepBackAbort(); } // Only composite nodes need to worry about which of their subtrees fired an abort. if (parent.MaxChildCount() > 1) { parent.OnAbort(aborter); } // Any requested traversals are cancelled on abort. _requestedTraversals.Clear(); Traverse(aborter); }