示例#1
0
        public static void Update(float totalTime)
        {
            // Get the instance
            TimerManager pInstance = TimerManager.PrivGetInstance();

            Debug.Assert(pInstance != null);

            // "Latch" the current time
            pInstance.currTime = totalTime;

            TimeEvent pEvent     = (TimeEvent)pInstance.BaseGetActive();
            TimeEvent pNextEvent = null;

            // Walk the list to end OR currTime is greater than timeEvent
            while (pEvent != null && (pInstance.currTime >= pEvent.GetTriggerTime()))
            {
                pNextEvent = (TimeEvent)pEvent.GetNext();

                if (pInstance.currTime >= pEvent.GetTriggerTime())
                {
                    // Process event
                    pEvent.Process();

                    // Remove from list
                    pInstance.BaseRemove(pEvent);
                }

                // Advance the pointer
                pEvent = pNextEvent;
            }
        }
示例#2
0
        private static void AddToActiveListInSortedOrder(TimerManager pInstance, TimeEvent pNewNode)
        {
            TimeEvent pListPointer = (TimeEvent)pInstance.BaseGetActive();

            if ((pListPointer == null) || (pNewNode.GetTriggerTime() <= pListPointer.GetTriggerTime()))
            {
                // If list is empty, or if pNode.triggerTime <= head.triggerTime
                // make the node as head
                pInstance.BaseSetActiveHead(pNewNode);
            }
            else
            {
                while (pListPointer != null)
                {
                    // If next TimeEvent has a greater triggerTime than new node, insert into list
                    if (pListPointer.GetTriggerTime() >= pNewNode.GetTriggerTime())
                    {
                        AddToListBeforeNode(pNewNode, pListPointer);

                        // Break loop
                        break;
                    }
                    else if (pListPointer.GetNext() == null)
                    {
                        AddToListAfterNode(pNewNode, pListPointer);
                        break;
                    }

                    pListPointer = (TimeEvent)pListPointer.GetNext();
                }
            }
        }
示例#3
0
        public static void Update(float totalTime)
        {
            // Get the instance
            TimerManager pMan = TimerManager.PrivGetInstance();

            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
            // List needs to be sorted by trigger time
            while (pEvent != null && (pMan.mCurrTime >= pEvent.triggerTime))
            {
                // 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.GetNext();

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

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

                // advance the pointer
                pEvent = pNextEvent;
            }
        }
        public static void Update(float totalTime)
        {
            // Get the instance
            TimerManager pMan = TimerManager.pActiveMan;

            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)// && (pMan.mCurrTime >= pEvent.triggerTime))
            {
                // 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)
                {
                    pEvent.Process();
                    pMan.BaseRemove(pEvent);
                }
                pEvent = pNextEvent;
            }
        }
        public static void Reset()
        {
            // Get the instance
            TimerManager pMan = TimerManager.pActiveMan;

            Debug.Assert(pMan != null);
            // walk the list
            TimeEvent pEvent     = (TimeEvent)pMan.BaseGetActive();
            TimeEvent pNextEvent = null;


            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;
                TimerManager.poNodeCopy.Set(pEvent.GetName(), pEvent.GetCommand(), pEvent.deltaTime);

                TimerManager.Remove(pEvent);
                TimerManager.Add(TimerManager.poNodeCopy.GetName(), TimerManager.poNodeCopy.GetCommand(), TimerManager.poNodeCopy.deltaTime);


                pEvent = pNextEvent;
            }
        }
示例#6
0
        public static void PullFromMemento(TimerMemento pMemento, float currTime)
        {
            float elapsedTime = currTime - pMemento.mCurrTime;

            Debug.Assert(elapsedTime >= 0);

            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            pMan.BasePullFromMemento(pMemento);

            // update all of the times on the event chain
            TimeEvent pNode = (TimeEvent)pMan.BaseGetActive();

            while (pNode != null)
            {
                pNode.triggerTime += elapsedTime;
                pNode              = (TimeEvent)pNode.GetNext();
            }
        }
示例#7
0
        public static void Update(float totalTime)
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            // squirrel away
            pMan.currentTime = 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
            while (pEvent != null && pMan.currentTime >= pEvent.triggerTime)
            {
                pNextEvent = (TimeEvent)pEvent.pNext;
                pEvent.Process();
                pMan.BaseRemove(pEvent);

                // advance the pointer
                pEvent = pNextEvent;
            }
        }