Exemple #1
0
        internal bool Loop(CoexEngine.Process process)
        {
            if (!gameObject.activeInHierarchy || !enabled || coexCount == 0)
            {
                StopAllCoroutines();
                Clear();
                return(false);
            }

            List <Coex> list = coexs[(int)process];

            for (int i = 0; i < list.Count;)
            {
                Coex coex = list[i];
                if (coex.state != Coex.State.Running)
                {
                    list.RemoveAt(i);
                    continue;
                }

                if (coex.frameCount != Time.frameCount)
                {
                    bool wait = false;
                    if (process == CoexEngine.Process.Update)
                    {
                        object rv = coex.returnValue;
                        if (null != rv)
                        {
                            wait = (rv is CoexWaitForSeconds && !((CoexWaitForSeconds)rv).timeout) ||
                                   (rv is WWW && !((WWW)rv).isDone) ||
                                   (rv is Coex && ((Coex)rv).state == Coex.State.Running);
                        }
                    }

                    if (!wait)
                    {
                        coex.MoveNext();
                        CoexEngine.Process dispatchProcess = Dispatch(coex);
                        if (dispatchProcess != process)
                        {
                            list.RemoveAt(i);
                            coexs[(int)dispatchProcess].Add(coex);
                            continue;
                        }
                    }
                }
                ++i;
            }
            return(true);
        }
Exemple #2
0
        internal Coex StartCoroutine(IEnumerator routine, Type rtType)
        {
            if (!addToEngine)
            {
                CoexEngine.Instance.AddBehaviour(this);
                addToEngine = true;
            }

            CheckReturnType(rtType);

            Coex c = new Coex(routine, rtType);

            c.MoveNext();
            if (c.state == Coex.State.Running)
            {
                c.process = Dispatch(c);
                coexs[(int)c.process].Add(c);
            }
            return(c);
        }