コード例 #1
0
        public static RadicalCoroutine Create(IEnumerator extendedCoRoutine, string debugName)
        {
            RadicalCoroutine radicalCoroutine = new RadicalCoroutine();

            radicalCoroutine.Enumerator = radicalCoroutine.Execute(extendedCoRoutine, debugName);
            return(radicalCoroutine);
        }
コード例 #2
0
        public static Coroutine Run(MonoBehaviour owner, IEnumerator extendedCoRoutine, string debugName)
        {
            RadicalCoroutine radicalCoroutine = new RadicalCoroutine();

            radicalCoroutine.Enumerator     = radicalCoroutine.Execute(extendedCoRoutine, debugName);
            radicalCoroutine.unityOwner     = owner;
            radicalCoroutine.unityCoroutine = owner.StartCoroutine(radicalCoroutine.Enumerator);
            return(radicalCoroutine.unityCoroutine);
        }
コード例 #3
0
        protected ICoroutine start(IEnumerator enumerator, object owner, string debugName, string prefix, CoroutineOwnerMap <RadicalCoroutine> map)
        {
            RadicalCoroutine radicalCoroutine = RadicalCoroutine.Create(enumerator, getDebugName(owner, debugName, prefix));

            map.Add(owner, radicalCoroutine);
            radicalCoroutine.unityOwner     = this;
            radicalCoroutine.unityCoroutine = StartCoroutine(radicalCoroutine.Enumerator);
            return(radicalCoroutine);
        }
コード例 #4
0
        private IEnumerator Execute(IEnumerator extendedCoroutine, string debugName)
        {
            trackedName = debugName;
            Timer       = Stopwatch.StartNew();
            if (Disposed)
            {
                yield break;
            }
            while (!Cancelled && extendedCoroutine != null)
            {
                Profiler.BeginSample(trackedName);
                bool res = extendedCoroutine.MoveNext();
                Profiler.EndSample();
                if (!res)
                {
                    break;
                }
                bool cancelledWhilePaused = false;
                if (Paused)
                {
                    if (ePaused != null)
                    {
                        ePaused();
                    }
                    while (Paused)
                    {
                        if (Cancelled)
                        {
                            cancelledWhilePaused = true;
                            break;
                        }
                        yield return(null);
                    }
                    if (eResumed != null && !Cancelled)
                    {
                        eResumed();
                    }
                }
                if (cancelledWhilePaused)
                {
                    break;
                }
                object          v  = extendedCoroutine.Current;
                CoroutineReturn cr = v as CoroutineReturn;
                ICoroutine      c  = v as ICoroutine;
                IEnumerator     e  = v as IEnumerator;
                if (cr != null)
                {
                    while (!cr.Finished)
                    {
                        yield return(null);
                    }
                }
                else if (c != null)
                {
                    while (!c.Disposed)
                    {
                        yield return(null);
                    }
                }
                else if (e != null)
                {
                    nestedRoutine                = Create(e, debugName + "+");
                    nestedRoutine.unityOwner     = unityOwner;
                    nestedRoutine.unityCoroutine = unityOwner.StartCoroutine(nestedRoutine.Enumerator);
                    yield return(nestedRoutine.unityCoroutine);

                    nestedRoutine = null;
                }
                else
                {
                    yield return(v);
                }
            }
            if (Disposed)
            {
                yield break;
            }
            if (Cancelled)
            {
                if (eCancelled != null)
                {
                    eCancelled();
                }
            }
            else
            {
                Completed = true;
                if (eCompleted != null)
                {
                    eCompleted();
                }
            }
            dispose();
        }