public bool MoveNext() { if (subRoutine != null) { if (subRoutine.shouldUpdate() && !subRoutine.MoveNext()) { subRoutine = null; return(MoveNext()); } else { return(true); } } else { return(moveThisNext()); } }
private bool runRoutine(IEnumerator routine) { bool moved = routine.MoveNext(); if (moved) { var thing = routine.Current; if (thing == null) { } else if (thing is TimeSpan waitSpan) { Console.WriteLine("coroutine will wait " + waitSpan); this.waitSpan = waitSpan; this.waitStartTime = DateTime.Now; } else if (thing is IEnumerator subRoutine) { if (this.subRoutine != null) { Console.WriteLine("\n\n!!!!setting subcoroutine even though one was already set and not null!!!!!\n\n"); } this.subRoutine = new CoRoutine(subRoutine); } else if (thing is IRoutineable subCoRoutine) { if (this.subRoutine != null) { Console.WriteLine("\n\n!!!!setting subcoroutine even though one was already set and not null!!!!!\n\n"); } this.subRoutine = subCoRoutine; } } return(moved); }