Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
        public static void Dump()
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            pMan.BaseDump();
        }
Ejemplo n.º 4
0
        public static float GetCurrTime()
        {
            // Get the instance
            TimerManager pTimerMan = TimerManager.PrivGetInstance();

            // return time
            return(pTimerMan.mCurrTime);
        }
Ejemplo n.º 5
0
        public static void Remove(TimeEvent pNode)
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            Debug.Assert(pNode != null);
            pMan.BaseRemove(pNode);
        }
Ejemplo n.º 6
0
        public static void PurgeAllNodes()
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            pMan.BasePurgeAllNodes();
        }
Ejemplo n.º 7
0
        public static void SetAlienDeltaTime(float newDeltaTime)
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            // return time
            pMan.deltaTimeForAlien = newDeltaTime;
        }
Ejemplo n.º 8
0
        public static float GetAlienDeltatTime()
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            // return time
            return(pMan.deltaTimeForAlien);
        }
Ejemplo n.º 9
0
        public static float GetCurrentTime()
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            // return time
            return(pMan.currentTime);
        }
Ejemplo n.º 10
0
        public static void PushToMemento(TimerMemento pMemento, float currTime)
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            pMan.BasePushToMemento(pMemento);
            pMemento.mCurrTime = currTime;
        }
Ejemplo n.º 11
0
        public static void Destroy()
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            // Do something clever here
            // track peak number of active nodes
            // print stats on destroy
            // invalidate the singleton
        }
Ejemplo n.º 12
0
        public static void Print()
        {
            TimerManager pInstance = TimerManager.PrivGetInstance();

            Debug.Assert(pInstance != null);

            Debug.WriteLine("******** TIMER MANAGER ****************");
            pInstance.PrintStats();
            pInstance.PrintNodes();
        }
Ejemplo n.º 13
0
        public static void PrintReport()
        {
            Debug.WriteLine("--------------------------------------------------------------------------------");
            Debug.WriteLine("--------------------------------- Timer Manager --------------------------------");
            Debug.WriteLine("--------------------------------------------------------------------------------");

            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            pMan.BasePrintReport();
        }
Ejemplo n.º 14
0
        public static TimeEvent Find(TimeEvent.Name name)
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            // So:  Use the Compare Node - as a reference
            //      use in the Compare() function
            pMan.poNodeCompare.name = name;
            TimeEvent pData = (TimeEvent)pMan.BaseFind(pInstance.poNodeCompare);

            return(pData);
        }
Ejemplo n.º 15
0
        public static TimeEvent Find(TimeEvent.Name name)
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            pMan.poNodeCompare.name = name;

            TimeEvent pData = (TimeEvent)pMan.BaseFind(pMan.poNodeCompare);

            Debug.Assert(pData != null);
            return(pData);
        }
Ejemplo n.º 16
0
        public static TimeEvent Pop()
        {
            TimerManager pInstance = TimerManager.PrivGetInstance();

            Debug.Assert(pInstance != null);

            DLink pNode = pInstance.pActive;

            if (pNode != null)
            {
                pInstance.BaseRemove(pNode);
            }

            return((TimeEvent)pNode);
        }
Ejemplo n.º 17
0
        public static TimeEvent Find(TimeEvent.Name name)
        {
            TimerManager pInstance = TimerManager.PrivGetInstance();

            Debug.Assert(pInstance != null);

            // Use compare node to compare to search nodes
            Debug.Assert(pInstance.pTimeEventCompare != null);
            pInstance.pTimeEventCompare.Clean();
            pInstance.pTimeEventCompare.SetName(name);

            TimeEvent pData = (TimeEvent)pInstance.BaseFind(pInstance.pTimeEventCompare);

            return(pData);
        }
Ejemplo n.º 18
0
        public static TimeEvent Add(TimeEvent.Name EventName, Command pCommand, float deltaTime)
        {
            Debug.Assert(pCommand != null);
            Debug.Assert(deltaTime > 0.0f);

            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            // Take a node out from Reserve list.
            // This node is washed in BasePopNode().
            TimeEvent pNode = (TimeEvent)pMan.BasePopNode();

            Debug.Assert(pNode != null);

            pNode.Set(EventName, pCommand, deltaTime);
            pMan.BaseSortedAdd(pNode);
            return(pNode);
        }
Ejemplo n.º 19
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();
            }
        }
Ejemplo n.º 20
0
        public static TimeEvent Add(TimeEvent.Name timeName, Command pCommand, float deltaTimeToTrigger)
        {
            Debug.Assert(pCommand != null);
            Debug.Assert(deltaTimeToTrigger >= 0.0f);

            // store these parameters to be used when BaseSpecializedAdd calls DerivedInitializeNode
            TimerManager.pTmpTimeName           = timeName;
            TimerManager.pTmpCommand            = pCommand;
            TimerManager.pTmpDeltaTimeToTrigger = deltaTimeToTrigger;

            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            TimeEvent pNode = (TimeEvent)pMan.BaseSpecializedAdd();

            Debug.Assert(pNode != null);

            return(pNode);
        }
Ejemplo n.º 21
0
        public static TimeEvent Add(TimeEvent.Name eventName, Command pCommand, float deltaTimeToTrigger)
        {
            TimerManager pInstance = TimerManager.PrivGetInstance();

            Debug.Assert(pInstance != null);

            // Retrieve a node from Reserve list
            TimeEvent pNewNode = (TimeEvent)pInstance.BaseGetNodeFromReserve();

            Debug.Assert(pNewNode != null);

            Debug.Assert(pCommand != null);
            Debug.Assert(deltaTimeToTrigger >= 0.0f);

            // Set TimerEvent attributes
            pNewNode.Set(eventName, pCommand, deltaTimeToTrigger);

            // Add to Active List in sorted order
            AddToActiveListInSortedOrder(pInstance, pNewNode);

            return(pNewNode);
        }
Ejemplo n.º 22
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;
            }
        }
Ejemplo n.º 23
0
        public static float GetCurrTime()
        {
            TimerManager pInstance = TimerManager.PrivGetInstance();

            return(pInstance.currTime);
        }