public static float GetCurrTime()
        {
            // Get the instance
            TimerEventManager pTimerEventManager = TimerEventManager.privGetInstance();

            // return time
            return(pTimerEventManager.currTime);
        }
        public static void DumpLists()
        {
            TimerEventManager pMan = TimerEventManager.privGetInstance();

            Debug.Assert(pMan != null);

            Debug.WriteLine("------ TimerEvent Manager Lists ------");
            pMan.baseDumpLists();
        }
        public static void Remove(TimerEvent pNode)
        {
            TimerEventManager pMan = TimerEventManager.privGetInstance();

            Debug.Assert(pMan != null);

            Debug.Assert(pNode != null);
            pMan.baseRemoveNode(pNode);
        }
        public static void Destroy()
        {
            // Get the instance
            TimerEventManager pMan = TimerEventManager.privGetInstance();

            Debug.WriteLine("--->TimerMan.Destroy()");
            pMan.baseDestroy();

#if (TRACK_DESTRUCTOR)
            Debug.WriteLine("     {0} ({1})", TimerMan.pTimerEventRef, TimerMan.pTimerEventRef.GetHashCode());
            Debug.WriteLine("     {0} ({1})", TimerMan.pInstance, TimerMan.pInstance.GetHashCode());
#endif
            TimerEventManager.pTimerEventRef = null;
            TimerEventManager.pInstance      = null;
        }
        public static TimerEvent Find(TimerEvent.Name name)
        {
            TimerEventManager pMan = TimerEventManager.privGetInstance();

            Debug.Assert(pMan != null);
            // Compare functions only compares two Nodes

            // So:  Use a reference node
            //      fill in the needed data
            //      use in the Compare() function
            Debug.Assert(pTimerEventRef != null);
            pTimerEventRef.Wash();
            pTimerEventRef.SetName(name);

            TimerEvent pData = (TimerEvent)pMan.baseFindNode(pTimerEventRef);

            return(pData);
        }
        //----------------------------------------------------------------------
        // Methods
        //----------------------------------------------------------------------
        public static TimerEvent Add(TimerEvent.Name timeName, Command pCommand, float deltaTimeToTrigger)
        {
            TimerEventManager pMan = TimerEventManager.privGetInstance();

            Debug.Assert(pMan != null);

            //pull a resereved node
            TimerEvent pNode = (TimerEvent)pMan.basePopReserve();

            Debug.Assert(pNode != null);

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

            //set the data
            pNode.Set(timeName, pCommand, deltaTimeToTrigger);

            //add the newly set timer event node to the list in sorted order
            pMan.baseAddSorted(pNode);

            return(pNode);
        }
        public static void Update(float totalTime)
        {
            // Get the instance
            TimerEventManager pTimerEventManager = TimerEventManager.privGetInstance();

            // store the current time
            pTimerEventManager.currTime = totalTime;

            // walk the event list
            TimerEvent pEvent    = (TimerEvent)pTimerEventManager.baseGetActive();
            TimerEvent nextEvent = null;

            // Walk the list until currTime is greater than timeEvent triggerTime
            while (pEvent != null)
            {
                // get the next event early in case this event executes and is removed
                nextEvent = (TimerEvent)pEvent.pMNext;

                if (pTimerEventManager.currTime >= pEvent.triggerTime)
                {
                    //Debug.WriteLine("{0} Event Triggered!", pEvent.GetName());
                    //Debug.WriteLine("Trigger Time:{0}", pTimerEventManager.currTime);
                    // execute the event
                    pEvent.Process();

                    // remove event from list after execution
                    pTimerEventManager.baseRemoveNode(pEvent);
                }
                else
                {
                    // early out, since the list is sorted
                    break;
                }

                // advance the pointer
                pEvent = nextEvent;
            }
        }