private bool IsNextRepeat() { if (_currentIndex - 1 >= 0) { Cooperator nextCooperator = _cooperators[_currentIndex - 1]; return(nextCooperator is CooperatorRepeat); } return(false); }
public CooperatorRepeat(Cooperator parent, int repeatCount) : base(parent) { _repeatCount = repeatCount; _predicate = () => { return(_repeatCurrentCount++ < _repeatCount); }; }
public static Cooperator YieldCoroutine(this Cooperator cooperator, IEnumerator appendCoroutine) { Cooperator appendCooperator = appendCoroutine as Cooperator; if (appendCooperator != null) { cooperator.Yield(appendCooperator.New()); } return(cooperator.Yield(appendCoroutine)); }
void IEnumerator.Reset() { _cooperators = new List <Cooperator>(); Cooperator curr = this; while (curr != null) { _cooperators.Add(curr); curr = curr.Parent; } _currentIndex = _cooperators.Count; Reset(); }
bool IEnumerator.MoveNext() { if (_currentIndex < 0) { (this as IEnumerator).Reset(); } bool isRepeatingRoutine = false; while (0 <= --_currentIndex) { if (isRepeatingRoutine == false && IsNextRepeat()) { continue; } Cooperator currCooperator = _cooperators[_currentIndex]; object prevInstruction = _current; object resultInstruction; if (currCooperator.Instruct(prevInstruction, out resultInstruction)) { _current = resultInstruction; return(true); } else { if (isRepeatingRoutine) { return(true); } if (currCooperator.IsRepeat()) { isRepeatingRoutine = true; _currentIndex += 2; } } } return(false); }
public static CooperatorFunc <TPrevInstruction, TCurrInstruction> YieldAction <TPrevInstruction, TCurrInstruction>(this Cooperator <TPrevInstruction> cooperator, Func <TPrevInstruction, TCurrInstruction> func) { return(new CooperatorFunc <TPrevInstruction, TCurrInstruction>(cooperator, func)); }
public CooperatorFunc(Cooperator parent, Func <TCurrInstruction> coroutine) : base(parent, default(TCurrInstruction)) { Coroutine = coroutine; }
public static Cooperator New(this Cooperator cooperator) { return(cooperator.Clone()); }
public static Cooperator <WaitForSeconds> YieldWaitForSeconds(this Cooperator cooperator, float seconds) { return(cooperator.Yield(new WaitForSeconds(seconds))); }
public static Cooperator <WaitForFixedUpdate> YieldWaitForFixedUpdate(this Cooperator cooperator) { return(cooperator.Yield(new WaitForFixedUpdate())); }
public static Cooperator <WaitForEndOfFrame> YieldWaitForEndOfFrame(this Cooperator cooperator) { return(cooperator.Yield(new WaitForEndOfFrame())); }
public static Cooperator <TCurrInstruction> Yield <TCurrInstruction>(this Cooperator cooperator, TCurrInstruction instruction) { return(new Cooperator <TCurrInstruction>(cooperator, instruction)); }
public static Cooperator <WWW> YieldWWW(this Cooperator cooperator, WWW www) { return(cooperator.Yield(www)); }
public static Cooperator YieldWaitForNextFrame(this Cooperator cooperator) { return(cooperator.Yield((object)null)); }
public static CooperatorRepeat Repeat <TCurrInstruction>(this Cooperator <TCurrInstruction> cooperator, Func <bool> predicate) { return(new CooperatorRepeat(cooperator, predicate)); }
public static CooperatorRepeat Repeat <TCurrInstruction>(this Cooperator <TCurrInstruction> cooperator, int repeatCount) { return(new CooperatorRepeat(cooperator, repeatCount)); }
public static Cooperator <WaitForSecondsRealtime> YieldWaitForSecondsRealtime(this Cooperator cooperator, float seconds) { return(cooperator.YieldAction(() => new WaitForSecondsRealtime(seconds))); }
public static Cooperator <TCurrInstruction> New <TCurrInstruction>(this Cooperator <TCurrInstruction> cooperator) { return(cooperator.Clone() as Cooperator <TCurrInstruction>); }
public static Cooperator <WaitWhile> YieldWaitWhile(this Cooperator cooperator, Func <bool> predicate) { return(cooperator.YieldAction(() => new WaitWhile(predicate))); }
public static Cooperator <AsyncOperation> YieldAsyncOperation(this Cooperator cooperator, AsyncOperation asyncOperation) { return(cooperator.Yield(asyncOperation)); }
public static Cooperator <TCustomYieldInstruction> YieldCustom <TCustomYieldInstruction>(this Cooperator cooperator, TCustomYieldInstruction customYieldInstruction) where TCustomYieldInstruction : CustomYieldInstruction { return(cooperator.Yield(customYieldInstruction)); }
public Cooperator(Cooperator parent) { Parent = parent; }
public static CooperatorAction Action(this Cooperator cooperator, Action action) { return(new CooperatorAction(cooperator, action)); }
public CooperatorRepeat(Cooperator parent, Func <bool> predicate) : base(parent) { _predicate = predicate; }
public static CooperatorAction <TPrevInstruction> Action <TPrevInstruction>(this Cooperator <TPrevInstruction> cooperator, Action <TPrevInstruction> action) { return(new CooperatorAction <TPrevInstruction>(cooperator, action)); }
public CooperatorAction(Cooperator parent, Action coroutine) : base(parent) { Coroutine = coroutine; }
public static Cooperator YieldCoroutine(this Cooperator cooperator, Coroutine appendCoroutine) { return(cooperator.Yield(appendCoroutine)); }