Beispiel #1
0
bool CClientFXMgr::UpdateAllActiveFX()
{
	//track our performance
	CTimedSystemBlock TimingBlock(g_tsClientFXUpdate);

	//Update our frame time, before any early outs so there aren't giant pops when the early
	//out fails
	float fFrameTime = m_Timer.GetTimerElapsedS();

	//add in all the effects from our next update list and clear that out
	LTListIter<CClientFXInstance*> itFXInstance = m_NextUpdateFXList.Begin();
	while(itFXInstance != m_NextUpdateFXList.End())
	{
		CClientFXInstance* pFXInstance = *itFXInstance;
		itFXInstance++;

		pFXInstance->m_FXListLink.Remove();
		m_FXInstanceList.AddTail(&pFXInstance->m_FXListLink);
	}

	HCONSOLEVAR hVar = m_pClientDE->GetConsoleVariable("UpdateClientFX");
	if (hVar)
	{
		float fVal = m_pClientDE->GetConsoleVariableFloat(hVar);

		if (!fVal) 
			return true;
	}

	//see if we should even update
	if( g_pGameClientShell->IsServerPaused( ))
	{
		//no time has elapsed, don't bother updating
		return true;
	}

	//
	// Update the group Instances
	//
	itFXInstance = m_FXInstanceList.Begin();
	while(itFXInstance != m_FXInstanceList.End())
	{
		CClientFXInstance* pInst = *itFXInstance;
		itFXInstance++;

		//see if this instance is suspended, if so, just call the suspended update
		if(pInst->UpdateSuspended())
		{
			//just run through all effects and give them a suspended updata
			LTListIter<CBaseFX*> itActiveFX = pInst->m_ActiveFXList.Begin();
			while(itActiveFX != pInst->m_ActiveFXList.End())
			{
				CBaseFX* pFX = *itActiveFX;
				itActiveFX++;
				pFX->SuspendedUpdate(fFrameTime);
			}

			//don't bother with any interval updating
			continue;
		}


		//determine the start and end of our update interval, relative to the instance
		//time frame
		float fStartInterval	= pInst->m_tmElapsed;
		float fEndInterval		= fStartInterval + fFrameTime;

		//we now need to iteratively break this interval down into a series of intervals that
		//do not extend past the end of the effect
		bool bLastSegment = false;
		while(!bLastSegment)
		{
			//pick whichever is closest, the end of the interval, or the duration of the
			//effect
			float fEndSegment = pInst->m_fDuration;

			if(fEndInterval < pInst->m_fDuration)
			{
				bLastSegment = true;
				fEndSegment = fEndInterval;
			}
			
			//alright, we now have an interval, update all the effects that lie within it
			pInst->UpdateInterval(fStartInterval, fEndSegment);

			//now move on to the next interval if necessary
			if(!bLastSegment)
			{
				fStartInterval	= 0.0f;
				fEndInterval	-= pInst->m_fDuration;
			}
		}

		//all done, save our time
		pInst->m_tmElapsed = fEndInterval;

		//see if we are done with this effect
		if(pInst->m_ActiveFXList.IsEmpty())
		{				
			// Destroy the instance
			DeleteClientFXInstance( pInst );
		}
	}

	// Success !!
	return true;
}