void C_ColorCorrection::Update( C_BasePlayer *pPlayer, float ccScale ) { Assert( m_CCHandle != INVALID_CLIENT_CCHANDLE ); if ( mat_colcorrection_disableentities.GetInt() ) { // Allow the colorcorrectionui panel (or user) to turn off color-correction entities g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f, m_bExclusive ); return; } int nSlot = GET_ACTIVE_SPLITSCREEN_SLOT(); bool bEnabled = IsClientSide() ? m_bEnabledOnClient[nSlot] : m_bEnabled; // fade weight on client if ( IsClientSide() ) { m_flCurWeightOnClient[nSlot] = Lerp( GetFadeRatio( nSlot ), m_flFadeStartWeight[nSlot], m_bFadingIn[nSlot] ? m_flMaxWeight : 0.0f ); } float flCurWeight = IsClientSide() ? m_flCurWeightOnClient[nSlot] : m_flCurWeight; if( !bEnabled && flCurWeight == 0.0f ) { g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f, m_bExclusive ); return; } Vector playerOrigin = pPlayer->GetAbsOrigin(); float weight = 0; if ( ( m_minFalloff != -1 ) && ( m_maxFalloff != -1 ) && m_minFalloff != m_maxFalloff ) { float dist = (playerOrigin - m_vecOrigin).Length(); weight = (dist-m_minFalloff) / (m_maxFalloff-m_minFalloff); if ( weight<0.0f ) weight = 0.0f; if ( weight>1.0f ) weight = 1.0f; } g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, flCurWeight * ( 1.0 - weight ) * ccScale, m_bExclusive ); }
void C_ColorCorrection::EnableOnClient( bool bEnable, bool bSkipFade ) { if ( !IsClientSide() ) { return; } int nSlot = GET_ACTIVE_SPLITSCREEN_SLOT(); if( m_bEnabledOnClient[nSlot] == bEnable ) { return; } m_bFadingIn[nSlot] = bEnable; m_bEnabledOnClient[nSlot] = bEnable; // initialize countdown timer m_flFadeStartWeight[nSlot] = m_flCurWeightOnClient[nSlot]; float flFadeTimeScale = 1.0f; if ( m_flMaxWeight != 0.0f ) { flFadeTimeScale = m_flCurWeightOnClient[nSlot] / m_flMaxWeight; } if ( m_bFadingIn[nSlot] ) { flFadeTimeScale = 1.0f - flFadeTimeScale; } if ( bSkipFade ) { flFadeTimeScale = 0.0f; } StartFade( nSlot, flFadeTimeScale * ( m_bFadingIn[nSlot] ? m_flFadeInDuration : m_flFadeOutDuration ) ); // update the clientside weight once here, in case the fade duration is 0 m_flCurWeightOnClient[nSlot] = Lerp( GetFadeRatio( nSlot ), m_flFadeStartWeight[nSlot], m_bFadingIn[nSlot] ? m_flMaxWeight : 0.0f ); }
void C_ColorCorrection::EnableOnClient( bool bEnable, bool bSkipFade ) { if ( !IsClientSide() ) { return; } if( m_bEnabledOnClient== bEnable ) { return; } m_bFadingIn = bEnable; m_bEnabledOnClient = bEnable; // initialize countdown timer m_flFadeStartWeight = m_flCurWeightOnClient; float flFadeTimeScale = 1.0f; if ( m_flMaxWeight != 0.0f ) { flFadeTimeScale = m_flCurWeightOnClient / m_flMaxWeight; } if ( m_bFadingIn ) { flFadeTimeScale = 1.0f - flFadeTimeScale; } if ( bSkipFade ) { flFadeTimeScale = 0.0f; } StartFade( flFadeTimeScale * ( m_bFadingIn ? m_flFadeInDuration : m_flFadeOutDuration ) ); // update the clientside weight once here, in case the fade duration is 0 m_flCurWeightOnClient = Lerp( GetFadeRatio(), m_flFadeStartWeight, m_bFadingIn ? m_flMaxWeight : 0.0f ); }