Esempio n. 1
0
        public static void Update(float totalTime)
        {
            TimerMan pMan = TimerMan.privGetInstance();

            Debug.Assert(pMan != null);

            pMan.mCurrTime = totalTime;

            TimeEvent pEvent     = (TimeEvent)pMan.baseGetActive();
            TimeEvent pNextEvent = null;

            while (pEvent != null)// && (pMan.mCurrTime >= pEvent.triggerTime))
            {
                pNextEvent = (TimeEvent)pEvent.pNext;

                if (pMan.mCurrTime >= pEvent.triggerTime)
                {
                    pEvent.Process();

                    pMan.baseRemove(pEvent);
                }

                pEvent = pNextEvent;
            }
        }
Esempio n. 2
0
        private static TimeEvent privSortedAdd(float deltaTimeToTrigger)
        {
            DLink     pLink;
            TimeEvent pCur;
            TimeEvent pTmp;

            //TimerMan pMan = TimerMan.privGetInstance();
            TimerMan pMan = TimerMan.pActiveTmMan;

            Debug.Assert(pMan != null);

            TimeEvent pTimeEvent = (TimeEvent)pMan.baseGetActive();
            TimeEvent pNode      = (TimeEvent)pMan.pullNodeFromReserve();

            float newTriggerTime = TimerMan.GetCurrTime() + deltaTimeToTrigger;

            if (pTimeEvent == null || pTimeEvent.triggerTime >= newTriggerTime)
            {
                pNode = (TimeEvent)pMan.baseAddEnd();
                Debug.Assert(pNode != null);
            }
            else
            {
                Debug.Assert(pNode != null);

                pCur = pTimeEvent;

                while (pCur.pNext != null)
                {
                    pTmp = (TimeEvent)pCur.pNext;

                    if (pTmp.triggerTime <= newTriggerTime)
                    {
                        pCur = (TimeEvent)pCur.pNext;
                        break;
                    }
                }

                pLink = (DLink)pCur;
                pNode = (TimeEvent)pMan.baseAddAfter(ref pLink, pNode);
                Debug.Assert(pNode != null);
            }

            return(pNode);
        }
Esempio n. 3
0
        public static void PauseUpdate(float delta)
        {
            // Get the instance
            //TimerMan pMan = TimerMan.privGetInstance();
            TimerMan pMan = TimerMan.pActiveTmMan;

            Debug.Assert(pMan != null);

            // walk the list
            TimeEvent pEvent = (TimeEvent)pMan.baseGetActive();

            while (pEvent != null)
            {
                pEvent.triggerTime += delta;
                // advance the pointer
                pEvent = (TimeEvent)pEvent.pNext;
            }
        }
Esempio n. 4
0
        public static void Update(float totalTime)
        {
            // Get the instance
            //TimerMan pMan = TimerMan.privGetInstance();
            TimerMan pMan = TimerMan.pActiveTmMan;

            Debug.Assert(pMan != null);

            // squirrel away
            pMan.mCurrTime = totalTime;

            // walk the list
            TimeEvent pEvent     = (TimeEvent)pMan.baseGetActive();
            TimeEvent pNextEvent = null;

            // Walk the list until there is no more list OR currTime is greater than timeEvent
            // ToDo Fix: List needs to be sorted
            while (pEvent != null)
            {
                // Difficult to walk a list and remove itself from the list
                // so squirrel away the next event now, use it at bottom of while
                pNextEvent = (TimeEvent)pEvent.pNext;

                if (pMan.mCurrTime >= pEvent.triggerTime)
                {
                    // call it
                    pEvent.Process();

                    // remove from list
                    pMan.baseRemove(pEvent);
                }

                // advance the pointer
                pEvent = pNextEvent;
            }
        }