示例#1
0
        /// Second param mean force dispose the coroutine. If false, the coroutine will be disposed when its reference count
        /// decreased to 0 automatically.
        static public void RemoveCoroutine(this object target, Coroutine pCoroutine, bool bDispose = false)
        {
            Debugger.Assert(!pCoroutine._bPooled);
            pCoroutine.DecRef();

            if (bDispose)
            {
                pCoroutine.Dispose();
            }
        }
示例#2
0
        override protected void _onRelease()
        {
            foreach (var co in _childCoroutines)
            {
                co.DecRef();
            }
            _childCoroutines.Clear();
            _pCoroutine.DecRef();

            _pCoroutine._OnChildCoStart -= _onChildCoStart;
            _pCoroutine._OnChildCoStop  -= _onChildCoStop;
        }
示例#3
0
        public void Reset()
        {
            Debugger.Assert(state == CoroutineState.Stopped);
            Debugger.Assert(_pCurrentInstruction == null);

            _AutoKill = true;

            _onUpdate    = null;
            _onComplete  = null;
            _onStopped   = null;
            _onStart     = null;
            _onException = null;
            _onYieldDone = null;

            if (_Parent != null)
            {
                _Parent.DecRef();
                _Parent = null;
            }

            __bIsManualStopped = false;
        }
示例#4
0
        internal void _Update(float fTime, float fRealTime)
        {
            _InUpdating = true;

            _Time     = fTime;
            _RealTime = fRealTime;

            if (__arrAddedCoroutines.Count != 0)
            {
                foreach (Coroutine addedCoroutine in __arrAddedCoroutines)
                {
                    _arrCoroutines.Add(addedCoroutine);
                }

                __arrAddedCoroutines.Clear();
            }

            ///-----
            int nAliveCount = _arrCoroutines.Count;

            Coroutine[] arrCoroutines = _arrCoroutines._Buffer;

            for (int i = 0; i < nAliveCount; ++i)
            {
                Coroutine pCoroutine = arrCoroutines[i];

                if (pCoroutine == null)
                {
                    int a = 0; a++;
                }

                Debugger.Assert(pCoroutine._bInQueue);

                bool bIsDead = pCoroutine._Update(pCoroutine.scalable ? fTime : fRealTime);

                if (bIsDead)
                {
                    if (i < nAliveCount - 1)
                    {
                        /// Swap with last element
                        _arrCoroutines[i] = _arrCoroutines[nAliveCount - 1];
                        i--;
                        nAliveCount--;
                    }
                    else if (i == nAliveCount - 1)
                    {
                        nAliveCount--;
                    }
                    else
                    {
                        Debugger.Assert(false);
                    }

                    _arrCoroutines.RemoveTail();

                    if (pCoroutine._bPooled)
                    {
                        pCoroutine.DecRef();
                    }
                    pCoroutine._bInQueue = false;
                }
            }

            _InUpdating = false;
        }