예제 #1
0
    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;
    }
 private IEnumerator parentCoroutine(CoroutineReturn childCoroutine)
 {
     yield return(childCoroutine);
 }