当前位置: 首页>>代码示例>>C++>>正文


C++ CTimeValue::GetMilliSeconds方法代码示例

本文整理汇总了C++中CTimeValue::GetMilliSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ CTimeValue::GetMilliSeconds方法的具体用法?C++ CTimeValue::GetMilliSeconds怎么用?C++ CTimeValue::GetMilliSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CTimeValue的用法示例。


在下文中一共展示了CTimeValue::GetMilliSeconds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnClientReceivedKill

void CLagOMeter::OnClientReceivedKill(const CActor::KillParams &killParams)
{
	CTimeValue currentTime = gEnv->pTimer->GetAsyncTime();
	if (killParams.shooterId == g_pGame->GetClientActorId())
	{
		// Try to find the corresponding request hit info to see how far lagged behind we are
		int index = killParams.lagOMeterHitId;
		if (index > 0 && index < HIT_HISTORY_COUNT)
		{
			SHitRequestHistory& item = m_hitHistory[index];
			if (item.requestTime.GetValue() != 0)
			{
				CTimeValue diff = currentTime - item.requestTime;
				CTelemetryCollector* pTelemetryCollector = (CTelemetryCollector*)g_pGame->GetITelemetryCollector();
				if (pTelemetryCollector)
				{
					pTelemetryCollector->LogEvent("Kill Latency", diff.GetMilliSeconds());
				}
			}
		}
	}
}
开发者ID:aronarts,项目名称:FireNET,代码行数:22,代码来源:LagOMeter.cpp

示例2: ShowMessage

void CMPTutorial::ShowMessage(STutorialEvent& event)
{
	assert(event.m_status == eMS_Waiting);

	// cancel previous sound if necessary
	if(m_currentEvent.m_pCurrentSound.get())
	{
		m_currentEvent.m_pCurrentSound->Stop(ESoundStopMode_AtOnce);
		m_currentEvent.m_pCurrentSound = NULL;
	}

	// also play the sound here
	if(gEnv->pSoundSystem && event.m_soundName.compare("None"))
	{
		string soundName = "mp_american/" + event.m_soundName;
		m_currentEvent.m_pCurrentSound = gEnv->pSoundSystem->CreateSound(soundName.c_str(),FLAG_SOUND_VOICE);
		if (m_currentEvent.m_pCurrentSound.get())
		{
			m_currentEvent.m_pCurrentSound->AddEventListener(this, "mptutorial");
			m_currentEvent.m_msgDisplayTime = 1000.0f;	// will be removed by sound finish event
			m_currentEvent.m_pCurrentSound->Play();
			m_currentEvent.m_soundLength = m_currentEvent.m_pCurrentSound->GetLengthMs();		// NB this almost certainly returns 0 as the sound isn't buffered yet :(
			CTimeValue time = gEnv->pTimer->GetFrameStartTime();
			m_currentEvent.m_soundStartTime = time.GetMilliSeconds();
		}
	}
	else
	{
		m_currentEvent.m_msgDisplayTime = MESSAGE_DISPLAY_TIME;

	}

	// create the localised text string from enum
	string msg;
	wstring localizedString;
	wstring finalString;
	ILocalizationManager *pLocalizationMan = gEnv->pSystem->GetLocalizationManager();
	if(!pLocalizationMan) 
		return;

	if(m_currentEvent.m_pCurrentSound)
	{
		msg = GetSoundKey(m_currentEvent.m_pCurrentSound->GetName());
		pLocalizationMan->GetSubtitle(msg.c_str(), localizedString, true);
	}
	else
	{
		msg = "@mp_Tut" + event.m_name;
		pLocalizationMan->LocalizeString(msg, localizedString);
	}

	if(localizedString.empty())
		return;

	// fill out keynames if necessary
	if(!strcmp(event.m_name, "BoardVehicle"))
	{
		// special case for this event - has 5 actions associated...
		string action1 = "@cc_";
		string action2 = "@cc_";
		string action3 = "@cc_";
		string action4 = "@cc_";
		string action5 = "@cc_";

		action1 += GetKeyName("v_changeseat1");
		action2 += GetKeyName("v_changeseat2");
		action3 += GetKeyName("v_changeseat3");
		action4 += GetKeyName("v_changeseat4");
		action5 += GetKeyName("v_changeseat5");

		wstring wActions[5];
		pLocalizationMan->LocalizeString(action1, wActions[0]);
		pLocalizationMan->LocalizeString(action2, wActions[1]);
		pLocalizationMan->LocalizeString(action3, wActions[2]);
		pLocalizationMan->LocalizeString(action4, wActions[3]);
		pLocalizationMan->LocalizeString(action5, wActions[4]);

		const wchar_t* params[] = {wActions[0].c_str(), wActions[1].c_str(), wActions[2].c_str(), wActions[3].c_str(), wActions[4].c_str()};
		pLocalizationMan->FormatStringMessage(finalString, localizedString, params, 5);
	}
	else if(!event.m_action.empty())
	{
		// first get the key name (eg 'mouse1') and make it into a format the localization system understands

		string action = "@cc_";
		action += GetKeyName(event.m_action.c_str());
		wstring wActionString;
		pLocalizationMan->LocalizeString(action, wActionString);

		// now place this in the right place in the string.
		pLocalizationMan->FormatStringMessage(finalString, localizedString, wActionString.c_str());
	}
	else
	{
		finalString = localizedString;
	}

	// split the text into chunks (to allow super-long strings to fit within the window)
	CreateTextChunks(finalString);

//.........这里部分代码省略.........
开发者ID:RenEvo,项目名称:dead6,代码行数:101,代码来源:MPTutorial.cpp

示例3: Update

void CMPTutorial::Update()
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_GAME);

	if(!m_enabled && g_pGameCVars->g_PSTutorial_Enabled)
		EnableTutorialMode(true);
	else if(m_enabled && !g_pGameCVars->g_PSTutorial_Enabled)
		EnableTutorialMode(false);

	m_currentEvent.m_msgDisplayTime -= gEnv->pTimer->GetFrameTime();
	if(!m_enabled)
	{	
		if(m_currentEvent.m_msgDisplayTime < 0.0f && m_currentEvent.m_msgRemovalCondition != eMRC_None)
		{
			m_currentEvent.m_msgRemovalCondition = eMRC_None;
			SAFE_HUD_FUNC(ShowTutorialText(NULL,1));
		}
	}

	// update the text... must be done even if not enabled, to ensure the 'you may reenable...' 
	//	message is shown correctly.
	if(m_currentEvent.m_numChunks > 0)
	{
		// calculate how far through the current sound we are
		CTimeValue now = gEnv->pTimer->GetFrameStartTime();
		float soundTimer = now.GetMilliSeconds() - m_currentEvent.m_soundStartTime;
		assert(soundTimer >= 0);
		float soundPercent = 1.0f;
		if(m_currentEvent.m_soundLength == 0.0f && m_currentEvent.m_pCurrentSound.get())
		{
			m_currentEvent.m_soundLength = m_currentEvent.m_pCurrentSound->GetLengthMs();
		}
		if(m_currentEvent.m_soundLength > 0.0f)
		{
			soundPercent = soundTimer / m_currentEvent.m_soundLength;
		}
		for(int i=m_currentEvent.m_numChunks-1; i > m_currentEvent.m_currentChunk; --i)
		{
			if(m_currentEvent.m_chunks[i].m_startPercent <= soundPercent)
			{
				m_currentEvent.m_currentChunk = i;

				int pos = 2; // 2=bottom, 1=middle
				IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor();	
				if(pClientActor && pClientActor->GetLinkedVehicle())
				{
					pos = 1;
				}

				SAFE_HUD_FUNC(ShowTutorialText(m_currentEvent.m_chunks[i].m_text, pos));
				break;
			}
		}
	}

	if(!m_enabled)
		return;

	CPlayer* pPlayer = static_cast<CPlayer*>(g_pGame->GetIGameFramework()->GetClientActor());
	if(!pPlayer)
		return;

	// don't start until game begins
	if(pPlayer->GetSpectatorMode() != 0 || g_pGame->GetGameRules()->GetCurrentStateId() != 3)
		return;

	if(!m_initialised)
	{
		m_initialised = true;

		if(g_pGame->GetHUD())
		{
			// register as a HUD listener
			g_pGame->GetHUD()->RegisterListener(this);
		}

		// go through entity list and pull out the factories.
		IEntityItPtr pIt = gEnv->pEntitySystem->GetEntityIterator();
		while (!pIt->IsEnd())
		{
			if (IEntity * pEnt = pIt->Next())
			{
				if(pEnt->GetClass() == m_pHQClass)
				{
					m_baseList.push_back(pEnt->GetId());
					//CryLog("Adding HQ %d to list: %d", pEnt->GetId(), m_baseList.size());
				}
				else if(pEnt->GetClass() == m_pAlienEnergyPointClass)
				{
					m_alienEnergyPointList.push_back(pEnt->GetId());
					//CryLog("Adding AEP %d to list: %d", pEnt->GetId(), m_alienEnergyPointList.size());
				}
				else if(pEnt->GetClass() == m_pSpawnGroupClass)
				{
					m_spawnGroupList.push_back(pEnt->GetId());
					//CryLog("Adding spawngroup %d to list: %d", pEnt->GetId(), m_spawnGroupList.size());
				}
				else if(pEnt->GetClass() == m_pFactoryClass)
				{
					m_factoryList.push_back(pEnt->GetId());
//.........这里部分代码省略.........
开发者ID:RenEvo,项目名称:dead6,代码行数:101,代码来源:MPTutorial.cpp

示例4: Serialize

void CFlowDelayNode::Serialize(SActivationInfo *pActInfo, TSerialize ser)
{
	CTimeValue curTime = gEnv->pTimer->GetFrameStartTime();

	ser.BeginGroup("Local");
	// Editor mode: map with
	// key:  abs time in ms
	// data: SDelayData
	//
	// Game mode: map with
	// key:  timer id (we don't care about it)
	// data: SDelayData
	if (ser.IsWriting()) {
		// when writing, currently relative values are stored!
		ser.Value("m_activations", m_activations);
#if 0
		CryLogAlways("CDelayNode write: current time(ms): %f", curTime.GetMilliSeconds());		
		Activations::iterator iter = m_activations.begin();
		while (iter != m_activations.end()) 
		{
			CryLogAlways("CDelayNode write: ms=%d  timevalue(ms): %f",(*iter).first, (*iter).second.m_timeout.GetMilliSeconds());
			++iter;
		}
#endif
	}
	else
	{
		// FIXME: should we read the curTime from the file
		//        or is the FrameStartTime already set to the serialized value?
		// ser.Value("curTime", curTime);

		// when reading we have to differentiate between Editor and Game Mode
		if (gEnv->IsEditor()) {
			// we can directly read into the m_activations array
			// regular update is handled by CFlowGraph
			ser.Value("m_activations", m_activations);
			Activations::iterator iter = m_activations.begin();
#if 0
			CryLogAlways("CDelayNode read: current time(ms): %f", curTime.GetMilliSeconds());		
			while (iter != m_activations.end()) 
			{
				CryLogAlways("CDelayNode read: ms=%d  timevalue(ms): %f",(*iter).first, (*iter).second.m_timeout.GetMilliSeconds());
				++iter;
			}
#endif
			pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID, !m_activations.empty());
		} else {
			RemovePendingTimers();
			// read serialized activations and re-register at timer
			Activations::iterator iter;
			Activations activations;
			ser.Value("m_activations", activations);
			for (iter = activations.begin(); iter != activations.end(); ++iter) {
				CTimeValue relTime = (*iter).second.m_timeout - curTime; 
				IGameFramework::TimerID timerId = CCryAction::GetCryAction()->AddTimer( relTime, false, functor(CFlowDelayNode::OnTimer),
					this );
				m_activations[timerId] = (*iter).second;
			}
		}
	}
	ser.EndGroup();
}
开发者ID:aronarts,项目名称:FireNET,代码行数:62,代码来源:FlowDelayNode.cpp

示例5: ProcessEvent

void CFlowDelayNode::ProcessEvent( EFlowEvent event, SActivationInfo * pActInfo )
{
	switch (event)
	{
	case eFE_Initialize:
		RemovePendingTimers();
		pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
		break;

	case eFE_Activate:
		// we request a final activation if the input value changed
		// thus in case we get several inputs in ONE frame, we always only use the LAST one!
		if (IsPortActive(pActInfo, INP_IN))
		{
			pActInfo->pGraph->RequestFinalActivation(pActInfo->myID);
		}
		break;

	case eFE_FinalActivate:
	{
		bool shouldReset = GetShouldReset( pActInfo );

		if (gEnv->IsEditor())
		{
			if (shouldReset)
				m_activations.clear();
			const float delay = GetDelayTime(pActInfo);
			CTimeValue finishTime = gEnv->pTimer->GetFrameStartTime() + delay;
			m_activations[(int)finishTime.GetMilliSeconds()] = SDelayData(finishTime, pActInfo->pInputPorts[0]);
			pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
		}
		else
		{
			if (shouldReset)
			{
				for (Activations::iterator iter = m_activations.begin(); iter != m_activations.end(); ++iter) 
				{
					IGameFramework::TimerID timerId = (*iter).first;
					CCryAction::GetCryAction()->RemoveTimer( timerId );
				}
				m_activations.clear();
			}

			const float delay = GetDelayTime(pActInfo);
			CTimeValue finishTime = gEnv->pTimer->GetFrameStartTime() + delay;
			IGameFramework::TimerID timerId = CCryAction::GetCryAction()->AddTimer( delay, false, functor(CFlowDelayNode::OnTimer),
				this );
			m_activations[timerId] = SDelayData(finishTime, pActInfo->pInputPorts[0]);
		}
		break;
	}

	case eFE_Update:
		CRY_ASSERT( gEnv->IsEditor() );
		CRY_ASSERT( !m_activations.empty() );
		CTimeValue curTime = gEnv->pTimer->GetFrameStartTime();

		while (!m_activations.empty() && m_activations.begin()->second.m_timeout < curTime)
		{
			ActivateOutput( pActInfo, 0, m_activations.begin()->second.m_data );
			m_activations.erase( m_activations.begin() );
		}
		if (m_activations.empty())
			pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
		break;
	}
}
开发者ID:aronarts,项目名称:FireNET,代码行数:67,代码来源:FlowDelayNode.cpp


注:本文中的CTimeValue::GetMilliSeconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。