Esempio n. 1
0
        /// <summary>
        /// Attempts to update the given Routine manually.
        /// </summary>
        public void RunManualUpdate(Fiber inFiber)
        {
            bool bPrevUpdating = m_ManualUpdateList.Updating;

            m_ManualUpdateList.Updating = true;
            inFiber.Update();
            m_ManualUpdateList.Updating = bPrevUpdating;
        }
Esempio n. 2
0
        bool IEnumerator.MoveNext()
        {
            if (m_Enumerator != null)
            {
                m_Fiber = m_Manager.ChainFiber(m_Enumerator);
                m_Fiber.SetNestedOwner(this);
                m_Fiber.SetParentFiber(m_ParentFiber);

                m_Enumerator = null;
            }

            if (m_Fiber != null)
            {
                if (m_Iterating)
                {
                    return(true);
                }

                m_Iterating = true;
                {
                    m_Accumulation += Routine.DeltaTime;
                    if (m_Accumulation > m_Interval)
                    {
                        // It's important that we reset timescale here.
                        // Otherwise timescale gets applied twice, resulting in inaccurate delta time values
                        float oldUnscaledTime = m_Manager.Frame.UnscaledDeltaTime;
                        float oldTimeScale    = m_Manager.Frame.TimeScale;
                        m_Manager.Frame.UnscaledDeltaTime = m_Accumulation;
                        m_Manager.Frame.TimeScale         = 1;
                        m_Manager.Frame.RefreshTimeScale();

                        m_Accumulation = 0;

                        bool bNext = m_Fiber.Update();

                        m_Manager.Frame.UnscaledDeltaTime = oldUnscaledTime;
                        m_Manager.Frame.TimeScale         = oldTimeScale;
                        m_Manager.Frame.RefreshTimeScale();

                        if (!bNext)
                        {
                            m_Fiber     = null;
                            m_Iterating = false;
                            return(false);
                        }
                    }
                }
                m_Iterating = false;
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        bool IEnumerator.MoveNext()
        {
            if (m_Enumerators != null)
            {
                for (int i = 0; i < m_Enumerators.Count; ++i)
                {
                    if (m_Enumerators[i] != null)
                    {
                        Fiber fiber = m_Manager.ChainFiber(m_Enumerators[i]);
                        fiber.SetNestedOwner(this);
                        fiber.SetParentFiber(m_ParentFiber);
                        m_Fibers.Add(fiber);
                    }
                }

                m_Enumerators.Clear();
                m_Enumerators = null;
                if (m_Fibers.Count == 0)
                {
                    return(false);
                }
            }

            if (m_Fibers != null)
            {
                if (m_Fibers.Count > 0)
                {
                    bool prevIterating = m_Iterating;
                    m_Iterating = true;
                    {
                        for (int i = 0; i < m_Fibers.Count; ++i)
                        {
                            Fiber myFiber = m_Fibers[i];
                            m_Manager.Frame.RefreshTimeScale();
                            if (!myFiber.Update())
                            {
                                m_Fibers.RemoveAt(i--);
                                if (m_Race)
                                {
                                    m_Iterating = false;
                                    return(false);
                                }
                            }
                        }
                    }
                    m_Iterating = prevIterating;
                }

                return(m_Fibers.Count > 0);
            }

            return(false);
        }