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 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; } }
public static void Dump() { TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); pMan.BaseDump(); }
public static float GetCurrTime() { // Get the instance TimerManager pTimerMan = TimerManager.PrivGetInstance(); // return time return(pTimerMan.mCurrTime); }
public static void Remove(TimeEvent pNode) { TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); Debug.Assert(pNode != null); pMan.BaseRemove(pNode); }
public static void PurgeAllNodes() { TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); pMan.BasePurgeAllNodes(); }
public static void SetAlienDeltaTime(float newDeltaTime) { TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); // return time pMan.deltaTimeForAlien = newDeltaTime; }
public static float GetAlienDeltatTime() { TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); // return time return(pMan.deltaTimeForAlien); }
public static float GetCurrentTime() { TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); // return time return(pMan.currentTime); }
public static void PushToMemento(TimerMemento pMemento, float currTime) { TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); pMan.BasePushToMemento(pMemento); pMemento.mCurrTime = currTime; }
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 }
public static void Print() { TimerManager pInstance = TimerManager.PrivGetInstance(); Debug.Assert(pInstance != null); Debug.WriteLine("******** TIMER MANAGER ****************"); pInstance.PrintStats(); pInstance.PrintNodes(); }
public static void PrintReport() { Debug.WriteLine("--------------------------------------------------------------------------------"); Debug.WriteLine("--------------------------------- Timer Manager --------------------------------"); Debug.WriteLine("--------------------------------------------------------------------------------"); TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); pMan.BasePrintReport(); }
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); }
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); }
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); }
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); }
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); }
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(); } }
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); }
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); }
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; } }
public static float GetCurrTime() { TimerManager pInstance = TimerManager.PrivGetInstance(); return(pInstance.currTime); }