/// <summary> /// 接收ConditionalAbort /// </summary> /// <param name="conditional">发起ConditionalAbort的<see cref="Conditional"/></param> /// <returns>是否成功接收</returns> public bool ReciveConditionalAbort(Conditional conditional) { int index = FindBranchIndex(conditional); if (index >= 0) { if (AbortSelf) { currentChild.Abort(); AbortFrom(index); } return(true); } return(false); }
private void PostConditionalAbort(Conditional conditional) { using var cEnum = evaluatedComposites.GetEnumerator(); //已进入评估的Composite优先级更高才有可能包含此Conditional并接收它发起的ConditionalAbort, //换句话说,此Conditional已进入评估,但包含它的Composite未进入评估,是不可能发生的。 while (cEnum.MoveNext() && cEnum.Current && cEnum.Current.ComparePriority(conditional)) { if (cEnum.Current.ReciveConditionalAbort(conditional)) { if (cEnum.Current.AbortLowerPriority)//接收了Abort,而且是中止低优先级,则向更先进入评估的Composite发起低优先中止 { PostLowerPriorityAbort(cEnum.Current); } } } }