////////////////////////////////////////////////////////////////////////// // Create a new timer and put it in the list of managed timers. int CScriptTimerMgr::AddTimer( ScriptTimer &timer ) { CTimeValue nCurrTimeMillis = gEnv->pTimer->GetFrameStartTime(); timer.nStartTime = nCurrTimeMillis.GetMilliSecondsAsInt64(); timer.nEndTime = timer.nStartTime + timer.nMillis; if (!timer.nTimerID) { m_nLastTimerID++; timer.nTimerID = m_nLastTimerID; } else { if (timer.nTimerID > m_nLastTimerID) m_nLastTimerID = timer.nTimerID+1; } m_mapTempTimers[timer.nTimerID] = new ScriptTimer(timer); return timer.nTimerID; }
//------------------------------------------------------------------------ void CGameRulesHoldObjectiveBase::AddEntityId(int type, EntityId entityId, int index, bool isNewEntity, const CTimeValue &timeAdded) { if(index >= HOLD_OBJECTIVE_MAX_ENTITIES) { CryFatalError("Too Many Hold Objective Entities Active!"); } CryLog("CGameRulesHoldObjectiveBase::AddEntityId() received objective, eid=%i, index=%i, isNewEntity=%s, fTimeAdded=%lld, adding to pending queue", entityId, index, isNewEntity ? "true" : "false", timeAdded.GetMilliSecondsAsInt64()); SHoldEntityDetails *pDetails = &m_entities[index]; if (pDetails->m_id) { // We're overwriting another entity, disable the old one CleanUpEntity(pDetails); } // Can't actually activate the entity here since the entity may not be fully initialised yet (horrible ordering issue on game restart), // instead set it as pending and do the actual add in the ::Update(...) method pDetails->m_pendingId = entityId; pDetails->m_isNewEntity = isNewEntity; m_pendingTimeAdded = timeAdded; }
static void SaveToXML(const XmlNodeRef& n, const char* name, const CTimeValue& t) { n->setAttr(name, t.GetMilliSecondsAsInt64()); }