public static RadicalRoutine StartExtendedCoroutine(this MonoBehaviour behaviour, IEnumerator coRoutine) { RadicalRoutine radicalRoutine = RadicalRoutine.Create(coRoutine); radicalRoutine.trackedObject = behaviour; radicalRoutine.Run(); return(radicalRoutine); }
public void Run(RadicalRoutine routine) { Running.Add(routine); if(routine.trackedObject) routine.trackedObject.StartCoroutine(routine.enumerator); else StartCoroutine(routine.enumerator); }
public static RadicalRoutine Create(IEnumerator extendedCoRoutine) { RadicalRoutine radicalRoutine = new RadicalRoutine(); radicalRoutine.extended = extendedCoRoutine; if (radicalRoutine.extended is INotifyStartStop) { (radicalRoutine.extended as INotifyStartStop).Start(); } radicalRoutine.enumerator = radicalRoutine.Execute(extendedCoRoutine); return(radicalRoutine); }
public void Run(RadicalRoutine routine) { this.Running.Add(routine); if (routine.trackedObject) { routine.trackedObject.StartCoroutine(routine.enumerator); } else { base.StartCoroutine(routine.enumerator); } }
public static RadicalRoutine Run(IEnumerator extendedCoRoutine, string methodName, object target) { RadicalRoutine radicalRoutine = new RadicalRoutine(); radicalRoutine.Method = methodName; radicalRoutine.Target = target; radicalRoutine.extended = extendedCoRoutine; if (radicalRoutine.extended is INotifyStartStop) { (radicalRoutine.extended as INotifyStartStop).Start(); } radicalRoutine.enumerator = radicalRoutine.Execute(extendedCoRoutine); RadicalRoutineHelper.Current.Run(radicalRoutine); return(radicalRoutine); }
public void Finished(RadicalRoutine routine) { Running.Remove(routine); if (!string.IsNullOrEmpty(routine.Method) && routine.Target != null) { try { var mi = routine.Target.GetType().GetMethod(routine.Method, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); if (mi != null) { mi.Invoke(routine.Target, new object[] { }); } } catch { } } }
public void Finished(RadicalRoutine routine) { Running.Remove(routine); if(!string.IsNullOrEmpty(routine.Method) && routine.Target != null) { try { var mi = routine.Target.GetType().GetMethod(routine.Method, BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.Static); if(mi != null) { mi.Invoke(routine.Target, new object [] {}); } } catch { } } }
public static RadicalRoutine Run(IEnumerator extendedCoRoutine, string methodName) { return(RadicalRoutine.Run(extendedCoRoutine, methodName, null)); }
public static RadicalRoutine Run(IEnumerator extendedCoRoutine) { return(RadicalRoutine.Run(extendedCoRoutine, string.Empty, null)); }
/// <summary> /// Creates a radical coroutine for a specific function /// </summary> /// <param name='extendedCoRoutine'> /// The function to use as a coroutine /// </param> public static RadicalRoutine Create(IEnumerator extendedCoRoutine) { var rr = new RadicalRoutine(); rr.extended = extendedCoRoutine; if (rr.extended is INotifyStartStop) { (rr.extended as INotifyStartStop).Start(); } rr.enumerator = rr.Execute(extendedCoRoutine); return rr; }
public static RadicalRoutine Run(IEnumerator extendedCoRoutine, string methodName, object target) { var rr = new RadicalRoutine(); rr.Method = methodName; rr.Target = target; rr.extended = extendedCoRoutine; if (rr.extended is INotifyStartStop) { (rr.extended as INotifyStartStop).Start(); } rr.enumerator = rr.Execute(extendedCoRoutine); RadicalRoutineHelper.Current.Run(rr); return rr; }
private IEnumerator Execute(IEnumerator extendedCoRoutine, Action complete) { Stack <IEnumerator> stack = new Stack <IEnumerator>(); stack.Push(extendedCoRoutine); while (stack.Count > 0) { extendedCoRoutine = stack.Pop(); while (!this.cancel && extendedCoRoutine != null && (!this.isTracking || (this.trackedObject != null && this.trackedObject.enabled)) && (LevelSerializer.IsDeserializing || extendedCoRoutine.MoveNext())) { object v = extendedCoRoutine.Current; CoroutineReturn cr = v as CoroutineReturn; if (cr != null) { if (cr.cancel) { this.cancel = true; break; } while (!cr.finished) { if (cr.cancel) { this.cancel = true; break; } yield return(null); } if (this.cancel) { break; } } else if (v is IYieldInstruction) { yield return((v as IYieldInstruction).Instruction); } if (v is IEnumerator) { stack.Push(extendedCoRoutine); extendedCoRoutine = (v as IEnumerator); } else if (v is RadicalRoutine) { RadicalRoutine rr = v as RadicalRoutine; while (!rr.finished) { yield return(null); } } else { yield return(v); } } } this.finished = true; this.Cancel(); if (this.cancel) { this.Cancelled(); } this.Finished(); if (complete != null) { complete(); } yield break; }
public static RadicalRoutine Create(IEnumerator extendedCoRoutine) { RadicalRoutine radicalRoutine = new RadicalRoutine(); radicalRoutine.extended = extendedCoRoutine; if (radicalRoutine.extended is INotifyStartStop) { (radicalRoutine.extended as INotifyStartStop).Start(); } radicalRoutine.enumerator = radicalRoutine.Execute(extendedCoRoutine); return radicalRoutine; }