public void Interrupt(BehaviourNode subroot, bool bFullInterrupt = false) { // Interrupt this subtree. subroot.Iterator.StepBackInterrupt(subroot, bFullInterrupt); // Look for parallel nodes under the subroot. // Since the parallel count is usually small, we // can just do a linear iteration to interrupt multiple // parallel nodes. for (int pIndex = 0; pIndex < _parallelNodeCount; ++pIndex) { Parallel p = _parallelNodes[pIndex]; if (IsUnderSubtree(subroot, p)) { for (int itrIndex = 0; itrIndex < p.ChildCount(); ++itrIndex) { BehaviourIterator itr = p.GetIterator(itrIndex); // Only interrupt running iterators. if (itr.IsRunning) { // Get the child of the parallel node, and interrupt the child subtree. int childIndex = itr.FirstInTraversal; BehaviourNode firstNode = allNodes[childIndex]; itr.StepBackInterrupt(firstNode.Parent, bFullInterrupt); } } } } }