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); }