void C_ASW_Alien::ClientThink() { BaseClass::ClientThink(); // asw temp fix demo playback //ASWUpdateClientSideAnimation(); m_vecLastRenderedPos = WorldSpaceCenter(); m_vecAutoTargetRadiusPos = GetLocalAutoTargetRadiusPos(); if ( GetHealth() > 0 && m_bElectroStunned && m_fNextElectroStunEffect <= gpGlobals->curtime) { // apply electro stun effect HACK_GETLOCALPLAYER_GUARD( "C_ASW_Alien::ClientThink FX_ElectroStun" ); FX_ElectroStun(this); m_fNextElectroStunEffect = gpGlobals->curtime + RandomFloat( 0.3, 1.0 ); //Msg( "%f - ElectroStunEffect\n", gpGlobals->curtime ); } UpdateFireEmitters(); C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer(); if ( pPlayer && pPlayer->IsSniperScopeActive() ) { m_GlowObject.SetRenderFlags( true, true ); } else { m_GlowObject.SetRenderFlags( false, false ); } }
//----------------------------------------------------------------------------- // Purpose: Don't allow recentering the mouse //----------------------------------------------------------------------------- void CASWInput::ResetMouse( void ) { HACK_GETLOCALPLAYER_GUARD( "Mouse behavior is tied to a specific player's status - splitscreen player would depend on which player (if any) is using mouse control" ); if ( MarineControllingTurret() || ( !asw_controls.GetBool() && ( !ASWGameRules() || ASWGameRules()->GetMarineDeathCamInterp() <= 0.0f ) && ( !C_ASW_Marine::GetLocalMarine() || !C_ASW_Marine::GetLocalMarine()->IsUsingComputerOrButtonPanel() ) ) ) { int x, y; GetWindowCenter( x, y ); SetMousePos( x, y ); } }
void C_GlobalLight::ClientThink() { VPROF("C_GlobalLight::ClientThink"); bool bSupressWorldLights = false; if ( cl_globallight_freeze.GetBool() == true ) { return; } //let us turn this shit on and off ingame m_bEnabled = cl_globallight_enabled.GetBool(); if ( m_bEnabled ) { Vector vLinearFloatLightColor( m_LightColor.r, m_LightColor.g, m_LightColor.b ); float flLinearFloatLightAlpha = m_LightColor.a; if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha ) { float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f; m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed ); m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed ); m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed ); m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed ); } FlashlightState_t state; Vector vDirection = m_shadowDirection; VectorNormalize( vDirection ); //Vector vViewUp = Vector( 0.0f, 1.0f, 0.0f ); Vector vSunDirection2D = vDirection; vSunDirection2D.z = 0.0f; HACK_GETLOCALPLAYER_GUARD( "C_GlobalLight::ClientThink" ); if ( !C_BasePlayer::GetLocalPlayer() ) return; Vector vPos; QAngle EyeAngles; float flZNear, flZFar, flFov; C_BasePlayer::GetLocalPlayer()->CalcView( vPos, EyeAngles, flZNear, flZFar, flFov ); // Vector vPos = C_BasePlayer::GetLocalPlayer()->GetAbsOrigin(); // vPos = Vector( 0.0f, 0.0f, 500.0f ); vPos = ( vPos + vSunDirection2D * m_flNorthOffset ) - vDirection * m_flSunDistance; vPos += Vector( cl_globallight_xoffset.GetFloat(), cl_globallight_yoffset.GetFloat(), 0.0f ); if (cl_globallight_showpos.GetBool() == true) { //ËÀË ß ÒÓÒÀ ÍÅÌÍÎÃÎ ÍÀØÊÎÄÈË, ÍÅ ÐÓÃÀÉÒÈÑ ÏËÇ ËÀÍÑÏÑ if (cl_globallight_xpos.GetFloat() !=0 && cl_globallight_ypos.GetFloat() !=0) { DevMsg("X = %3.0f\n Y = %3.0f\n", cl_globallight_xpos.GetFloat(), cl_globallight_ypos.GetFloat()); } else DevMsg("X = %3.0f\n Y = %3.0f\n", vPos.x, vPos.y); } if (cl_globallight_xpos.GetFloat() !=0 && cl_globallight_ypos.GetFloat() !=0) { vPos.x = cl_globallight_xpos.GetFloat(); vPos.y = cl_globallight_ypos.GetFloat(); } QAngle angAngles; VectorAngles( vDirection, angAngles ); Vector vForward, vRight, vUp; AngleVectors( angAngles, &vForward, &vRight, &vUp ); state.m_fHorizontalFOVDegrees = m_flFOV; state.m_fVerticalFOVDegrees = m_flFOV; state.m_vecLightOrigin = vPos; BasisToQuaternion( vForward, vRight, vUp, state.m_quatOrientation ); state.m_fQuadraticAtten = 0.0f; state.m_fLinearAtten = m_flSunDistance * 2.0f; state.m_fConstantAtten = 0.0f; state.m_FarZAtten = m_flSunDistance * 2.0f; state.m_Color[0] = m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha; state.m_Color[1] = m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha; state.m_Color[2] = m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha; state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient; state.m_NearZ = 4.0f; state.m_FarZ = m_flSunDistance * 2.0f; state.m_fBrightnessScale = 1.0f; state.m_bGlobalLight = true; float flOrthoSize = cl_globallight_orthosize.GetFloat(); if ( flOrthoSize > 0 ) { state.m_bOrtho = true; state.m_fOrthoLeft = -flOrthoSize; state.m_fOrthoTop = -flOrthoSize; state.m_fOrthoRight = flOrthoSize; state.m_fOrthoBottom = flOrthoSize; } else { state.m_bOrtho = false; } state.m_bDrawShadowFrustum = cl_globallight_drawfrustum.GetBool(); state.m_flShadowSlopeScaleDepthBias = 1.0f; state.m_flShadowDepthBias = g_pMaterialSystemHardwareConfig->GetShadowDepthBias(); state.m_bEnableShadows = m_bEnableShadows; state.m_pSpotlightTexture = m_SpotlightTexture; state.m_pProjectedMaterial = NULL; // don't complain cause we aren't using simple projection in this class state.m_nSpotlightTextureFrame = 0; state.m_flShadowFilterSize = 0.2f; //state.m_nShadowQuality = 1; // Allow entity to affect shadow quality state.m_bShadowHighRes = true; if ( m_bOldEnableShadows != m_bEnableShadows ) { // If they change the shadow enable/disable, we need to make a new handle if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE ) { g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle ); m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE; } m_bOldEnableShadows = m_bEnableShadows; } if( m_LocalFlashlightHandle == CLIENTSHADOW_INVALID_HANDLE ) { m_LocalFlashlightHandle = g_pClientShadowMgr->CreateFlashlight( state ); } else { g_pClientShadowMgr->UpdateFlashlightState( m_LocalFlashlightHandle, state ); g_pClientShadowMgr->UpdateProjectedTexture( m_LocalFlashlightHandle, true ); } bSupressWorldLights = m_bEnableShadows; } else if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE ) { g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle ); m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE; } BaseClass::ClientThink(); }
void C_EnvProjectedTexture::UpdateLight( void ) { VPROF("C_EnvProjectedTexture::UpdateLight"); bool bVisible = true; Vector vLinearFloatLightColor( m_LightColor.r, m_LightColor.g, m_LightColor.b ); float flLinearFloatLightAlpha = m_LightColor.a; if ( m_bAlwaysUpdate ) { m_bForceUpdate = true; } if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha ) { float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f; m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed ); m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed ); m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed ); m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed ); m_bForceUpdate = true; } if ( !m_bForceUpdate ) { bVisible = IsBBoxVisible(); } if ( m_bState == false || !bVisible ) { // Spotlight's extents aren't in view ShutDownLightHandle(); return; } if ( m_LightHandle == CLIENTSHADOW_INVALID_HANDLE || m_hTargetEntity != NULL || m_bForceUpdate ) { Vector vForward, vRight, vUp, vPos = GetAbsOrigin(); FlashlightState_t state; if ( m_hTargetEntity != NULL ) { if ( m_bCameraSpace ) { const QAngle &angles = GetLocalAngles(); C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if( pPlayer ) { const QAngle playerAngles = pPlayer->GetAbsAngles(); Vector vPlayerForward, vPlayerRight, vPlayerUp; AngleVectors( playerAngles, &vPlayerForward, &vPlayerRight, &vPlayerUp ); matrix3x4_t mRotMatrix; AngleMatrix( angles, mRotMatrix ); VectorITransform( vPlayerForward, mRotMatrix, vForward ); VectorITransform( vPlayerRight, mRotMatrix, vRight ); VectorITransform( vPlayerUp, mRotMatrix, vUp ); float dist = (m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin()).Length(); vPos = m_hTargetEntity->GetAbsOrigin() - vForward*dist; VectorNormalize( vForward ); VectorNormalize( vRight ); VectorNormalize( vUp ); } } else { vForward = m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin(); VectorNormalize( vForward ); // JasonM - unimplemented Assert (0); //Quaternion q = DirectionToOrientation( dir ); // // JasonM - set up vRight, vUp // // VectorNormalize( vRight ); // VectorNormalize( vUp ); } } else { AngleVectors( GetAbsAngles(), &vForward, &vRight, &vUp ); } state.m_fHorizontalFOVDegrees = m_flLightFOV; state.m_fVerticalFOVDegrees = m_flLightFOV; state.m_vecLightOrigin = vPos; BasisToQuaternion( vForward, vRight, vUp, state.m_quatOrientation ); state.m_NearZ = m_flNearZ; state.m_FarZ = m_flFarZ; // quickly check the proposed light's bbox against the view frustum to determine whether we // should bother to create it, if it doesn't exist, or cull it, if it does. if ( m_bSimpleProjection == false ) { #pragma message("OPTIMIZATION: this should be made SIMD") // get the half-widths of the near and far planes, // based on the FOV which is in degrees. Remember that // on planet Valve, x is forward, y left, and z up. const float tanHalfAngle = tan( m_flLightFOV * ( M_PI/180.0f ) * 0.5f ); const float halfWidthNear = tanHalfAngle * m_flNearZ; const float halfWidthFar = tanHalfAngle * m_flFarZ; // now we can build coordinates in local space: the near rectangle is eg // (0, -halfWidthNear, -halfWidthNear), (0, halfWidthNear, -halfWidthNear), // (0, halfWidthNear, halfWidthNear), (0, -halfWidthNear, halfWidthNear) VectorAligned vNearRect[4] = { VectorAligned( m_flNearZ, -halfWidthNear, -halfWidthNear), VectorAligned( m_flNearZ, halfWidthNear, -halfWidthNear), VectorAligned( m_flNearZ, halfWidthNear, halfWidthNear), VectorAligned( m_flNearZ, -halfWidthNear, halfWidthNear) }; VectorAligned vFarRect[4] = { VectorAligned( m_flFarZ, -halfWidthFar, -halfWidthFar), VectorAligned( m_flFarZ, halfWidthFar, -halfWidthFar), VectorAligned( m_flFarZ, halfWidthFar, halfWidthFar), VectorAligned( m_flFarZ, -halfWidthFar, halfWidthFar) }; matrix3x4_t matOrientation( vForward, -vRight, vUp, vPos ); enum { kNEAR = 0, kFAR = 1, }; VectorAligned vOutRects[2][4]; for ( int i = 0 ; i < 4 ; ++i ) { VectorTransform( vNearRect[i].Base(), matOrientation, vOutRects[0][i].Base() ); } for ( int i = 0 ; i < 4 ; ++i ) { VectorTransform( vFarRect[i].Base(), matOrientation, vOutRects[1][i].Base() ); } // now take the MIN and MAX extents for the bbox, and see if it is visible. Vector mins = **vOutRects; Vector maxs = **vOutRects; for ( int i = 1; i < 8 ; ++i ) { VectorMin( mins, *(*vOutRects+i), mins ); VectorMax( maxs, *(*vOutRects+i), maxs ); } #if 0 //for debugging the visibility frustum we just calculated NDebugOverlay::Triangle( vOutRects[0][0], vOutRects[0][1], vOutRects[0][2], 255, 0, 0, 100, true, 0.0f ); //first tri NDebugOverlay::Triangle( vOutRects[0][2], vOutRects[0][1], vOutRects[0][0], 255, 0, 0, 100, true, 0.0f ); //make it double sided NDebugOverlay::Triangle( vOutRects[0][2], vOutRects[0][3], vOutRects[0][0], 255, 0, 0, 100, true, 0.0f ); //second tri NDebugOverlay::Triangle( vOutRects[0][0], vOutRects[0][3], vOutRects[0][2], 255, 0, 0, 100, true, 0.0f ); //make it double sided NDebugOverlay::Triangle( vOutRects[1][0], vOutRects[1][1], vOutRects[1][2], 0, 0, 255, 100, true, 0.0f ); //first tri NDebugOverlay::Triangle( vOutRects[1][2], vOutRects[1][1], vOutRects[1][0], 0, 0, 255, 100, true, 0.0f ); //make it double sided NDebugOverlay::Triangle( vOutRects[1][2], vOutRects[1][3], vOutRects[1][0], 0, 0, 255, 100, true, 0.0f ); //second tri NDebugOverlay::Triangle( vOutRects[1][0], vOutRects[1][3], vOutRects[1][2], 0, 0, 255, 100, true, 0.0f ); //make it double sided NDebugOverlay::Box( vec3_origin, mins, maxs, 0, 255, 0, 100, 0.0f ); #endif bool bVisible = IsBBoxVisible( mins, maxs ); if (!bVisible) { // Spotlight's extents aren't in view if ( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE ) { ShutDownLightHandle(); } return; } } float flAlpha = m_flCurrentLinearFloatLightAlpha * ( 1.0f / 255.0f ); state.m_fQuadraticAtten = 0.0; state.m_fLinearAtten = 100; state.m_fConstantAtten = 0.0f; state.m_FarZAtten = m_flFarZ; state.m_fBrightnessScale = m_flBrightnessScale; state.m_Color[0] = m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * flAlpha; state.m_Color[1] = m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * flAlpha; state.m_Color[2] = m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * flAlpha; state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient; state.m_flShadowSlopeScaleDepthBias = g_pMaterialSystemHardwareConfig->GetShadowSlopeScaleDepthBias(); state.m_flShadowDepthBias = g_pMaterialSystemHardwareConfig->GetShadowDepthBias(); state.m_bEnableShadows = m_bEnableShadows; state.m_pSpotlightTexture = m_SpotlightTexture; state.m_pProjectedMaterial = NULL; // only complain if we're using material projection state.m_nSpotlightTextureFrame = m_nSpotlightTextureFrame; state.m_flProjectionSize = m_flProjectionSize; state.m_flProjectionRotation = m_flRotation; state.m_nShadowQuality = m_nShadowQuality; // Allow entity to affect shadow quality if ( m_bSimpleProjection == true ) { state.m_bSimpleProjection = true; state.m_bOrtho = true; state.m_fOrthoLeft = -m_flProjectionSize; state.m_fOrthoTop = -m_flProjectionSize; state.m_fOrthoRight = m_flProjectionSize; state.m_fOrthoBottom = m_flProjectionSize; } if( m_LightHandle == CLIENTSHADOW_INVALID_HANDLE ) { // Hack: env projected textures don't work like normal flashlights; they're not assigned to a given splitscreen slot, // but the flashlight code requires this HACK_GETLOCALPLAYER_GUARD( "Env projected texture" ); if ( m_bSimpleProjection == true ) { m_LightHandle = g_pClientShadowMgr->CreateProjection( state ); } else { m_LightHandle = g_pClientShadowMgr->CreateFlashlight( state ); } if ( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE ) { m_bForceUpdate = false; } } else { if ( m_bSimpleProjection == true ) { g_pClientShadowMgr->UpdateProjectionState( m_LightHandle, state ); } else { g_pClientShadowMgr->UpdateFlashlightState( m_LightHandle, state ); } m_bForceUpdate = false; } g_pClientShadowMgr->GetFrustumExtents( m_LightHandle, m_vecExtentsMin, m_vecExtentsMax ); m_vecExtentsMin = m_vecExtentsMin - GetAbsOrigin(); m_vecExtentsMax = m_vecExtentsMax - GetAbsOrigin(); } if( m_bLightOnlyTarget ) { g_pClientShadowMgr->SetFlashlightTarget( m_LightHandle, m_hTargetEntity ); } else { g_pClientShadowMgr->SetFlashlightTarget( m_LightHandle, NULL ); } g_pClientShadowMgr->SetFlashlightLightWorld( m_LightHandle, m_bLightWorld ); if ( !asw_perf_wtf.GetBool() && !m_bForceUpdate ) { g_pClientShadowMgr->UpdateProjectedTexture( m_LightHandle, true ); } }
void C_SunlightShadowControl::ClientThink() { VPROF("C_SunlightShadowControl::ClientThink"); if ( m_bEnabled ) { Vector vLinearFloatLightColor( m_LightColor.r, m_LightColor.g, m_LightColor.b ); float flLinearFloatLightAlpha = m_LightColor.a; if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha ) { float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f; m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed ); m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed ); m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed ); m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed ); } FlashlightState_t state; Vector vDirection = m_shadowDirection; VectorNormalize( vDirection ); QAngle angView; engine->GetViewAngles( angView ); //Vector vViewUp = Vector( 0.0f, 1.0f, 0.0f ); Vector vSunDirection2D = vDirection; vSunDirection2D.z = 0.0f; HACK_GETLOCALPLAYER_GUARD( "C_SunlightShadowControl::ClientThink" ); #ifdef INFESTED_DLL // shine sun on your current marine, rather than the player entity C_ASW_Marine *pMarine = C_ASW_Marine::GetLocalMarine(); if ( !pMarine ) return; Vector vPos = ( pMarine->GetAbsOrigin() + vSunDirection2D * m_flNorthOffset ) - vDirection * m_flSunDistance; #else if ( !C_BasePlayer::GetLocalPlayer() ) return; Vector vPos = ( C_BasePlayer::GetLocalPlayer()->GetAbsOrigin() + vSunDirection2D * m_flNorthOffset ) - vDirection * m_flSunDistance; #endif QAngle angAngles; VectorAngles( vDirection, angAngles ); Vector vForward, vRight, vUp; AngleVectors( angAngles, &vForward, &vRight, &vUp ); state.m_fHorizontalFOVDegrees = m_flFOV; state.m_fVerticalFOVDegrees = m_flFOV; state.m_vecLightOrigin = vPos; BasisToQuaternion( vForward, vRight, vUp, state.m_quatOrientation ); state.m_fQuadraticAtten = 0.0f; state.m_fLinearAtten = m_flSunDistance / 2.0f; state.m_fConstantAtten = 0.0f; state.m_FarZAtten = m_flSunDistance + 300.0f; state.m_Color[0] = m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha; state.m_Color[1] = m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha; state.m_Color[2] = m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha; state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient; state.m_NearZ = fpmax( 4.0f, m_flSunDistance - m_flNearZ ); state.m_FarZ = m_flSunDistance + 300.0f; float flOrthoSize = cl_sunlight_ortho_size.GetFloat(); if ( flOrthoSize > 0 ) { state.m_bOrtho = true; state.m_fOrthoLeft = -flOrthoSize; state.m_fOrthoTop = -flOrthoSize; state.m_fOrthoRight = flOrthoSize; state.m_fOrthoBottom = flOrthoSize; } else { state.m_bOrtho = false; } state.m_flShadowSlopeScaleDepthBias = 2; state.m_flShadowDepthBias = cl_sunlight_depthbias.GetFloat(); state.m_bEnableShadows = m_bEnableShadows; state.m_pSpotlightTexture = m_SpotlightTexture; state.m_pProjectedMaterial = NULL; state.m_nSpotlightTextureFrame = 0; state.m_nShadowQuality = 1; // Allow entity to affect shadow quality state.m_bShadowHighRes = true; if ( m_bOldEnableShadows != m_bEnableShadows ) { // If they change the shadow enable/disable, we need to make a new handle if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE ) { g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle ); m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE; } m_bOldEnableShadows = m_bEnableShadows; } if( m_LocalFlashlightHandle == CLIENTSHADOW_INVALID_HANDLE ) { m_LocalFlashlightHandle = g_pClientShadowMgr->CreateFlashlight( state ); } else { g_pClientShadowMgr->UpdateFlashlightState( m_LocalFlashlightHandle, state ); #ifndef INFESTED_DLL #pragma message("TODO: rebuild sunlight projected texture after sunlight control changes.") g_pClientShadowMgr->UpdateProjectedTexture( m_LocalFlashlightHandle, true ); #endif } } else if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE ) { g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle ); m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE; } BaseClass::ClientThink(); }
void C_ASW_Hack_Wire_Tile::ClientThink() { HACK_GETLOCALPLAYER_GUARD( "Need to support launching multiple hack panels on one machine (1 for each splitscreen player) for this to make sense." ); if (m_bLaunchedHackPanel) // if we've launched our hack window, but the hack has lost its hacking marine, then close our window down { bool bStillUsing = true; if (!GetHackerMarineResource()) bStillUsing = false; if (!bStillUsing) { //Msg("wire hack has lost his hacking marine\n"); m_bLaunchedHackPanel = false; if (m_hFrame.Get()) { m_hFrame->SetVisible(false); m_hFrame->MarkForDeletion(); m_hFrame = NULL; ASWInput()->SetCameraFixed( false ); } } } // if we haven't launched the window and data is all present, launch it if (!m_bLaunchedHackPanel && m_iNumWires > 0 && GetHackerMarineResource() != NULL) { vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/SwarmSchemeNew.res", "SwarmSchemeNew"); m_hFrame = new CASW_VGUI_Hack_Wire_Tile_Container( GetClientMode()->GetViewport(), "WireTileContainer", this); m_hFrame->SetScheme(scheme); CASW_VGUI_Hack_Wire_Tile* pHackWireFrame = new CASW_VGUI_Hack_Wire_Tile( m_hFrame.Get(), "HackWireTile", this ); pHackWireFrame->SetScheme(scheme); pHackWireFrame->ASWInit(); pHackWireFrame->MoveToFront(); pHackWireFrame->RequestFocus(); pHackWireFrame->SetVisible(true); pHackWireFrame->SetEnabled(true); m_bLaunchedHackPanel = true; } // check for hiding the panel if the player has a different marine selected, or if the selected marine is remote controlling a turret if (m_bLaunchedHackPanel && GetHackerMarineResource() && m_hFrame.Get()) { C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer(); if (!pPlayer) { m_hFrame->SetVisible(false); } else { bool bLocalPlayerControllingHacker = (GetHackerMarineResource()->IsInhabited() && GetHackerMarineResource()->GetCommanderIndex() == pPlayer->entindex()); bool bMarineControllingTurret = (GetHackerMarineResource()->GetMarineEntity() && GetHackerMarineResource()->GetMarineEntity()->IsControllingTurret()); if (bLocalPlayerControllingHacker && !bMarineControllingTurret) { ASWInput()->SetCameraFixed( true ); m_hFrame->SetVisible(true); if (gpGlobals->curtime > m_fNextLockCycleTime) { m_fNextLockCycleTime = gpGlobals->curtime + asw_hack_cycle_time.GetFloat(); CycleRows(); } } else { ASWInput()->SetCameraFixed( false ); m_hFrame->SetVisible(false); } } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CParticleProperty::UpdateControlPoint( ParticleEffectList_t *pEffect, int iPoint, bool bInitializing ) { ParticleControlPoint_t *pPoint = &pEffect->pControlPoints[iPoint]; if ( pEffect->pParticleEffect->m_pDef->IsScreenSpaceEffect() && iPoint == 0 ) { pEffect->pParticleEffect->SetControlPointOrientation( pPoint->iControlPoint, Vector(1,0,0), Vector(0,1,0), Vector(0,0,1) ); pEffect->pParticleEffect->SetControlPoint( pPoint->iControlPoint, vec3_origin ); return; } if ( !pPoint->hEntity.Get() ) { if ( pPoint->iAttachType == PATTACH_WORLDORIGIN && bInitializing ) { pEffect->pParticleEffect->SetControlPointOrientation( pPoint->iControlPoint, Vector(1,0,0), Vector(0,1,0), Vector(0,0,1) ); pEffect->pParticleEffect->SetControlPoint( pPoint->iControlPoint, pPoint->vecOriginOffset ); pEffect->pParticleEffect->SetSortOrigin( pPoint->vecOriginOffset ); } pEffect->pParticleEffect->SetControlPointEntity( pPoint->iControlPoint, NULL ); return; } // Only update non-follow particles when we're initializing, if ( !bInitializing && (pPoint->iAttachType == PATTACH_ABSORIGIN || pPoint->iAttachType == PATTACH_POINT ) ) return; if ( pPoint->iAttachType == PATTACH_CUSTOMORIGIN ) return; Vector vecOrigin, vecForward, vecRight, vecUp; switch ( pPoint->iAttachType ) { case PATTACH_POINT: case PATTACH_POINT_FOLLOW: { C_BaseAnimating *pAnimating = pPoint->hEntity->GetBaseAnimating(); bool bValid = false; Assert( pAnimating ); if ( pAnimating ) { matrix3x4_t attachmentToWorld; if ( pAnimating->IsViewModel() ) { C_BasePlayer *pPlayer = ToBasePlayer( ((C_BaseViewModel *)pAnimating)->GetOwner() ); ACTIVE_SPLITSCREEN_PLAYER_GUARD( C_BasePlayer::GetSplitScreenSlotForPlayer( pPlayer ) ); if ( pAnimating->GetAttachment( pPoint->iAttachmentPoint, attachmentToWorld ) ) { bValid = true; MatrixVectors( attachmentToWorld, &vecForward, &vecRight, &vecUp ); MatrixPosition( attachmentToWorld, vecOrigin ); if ( pEffect->pParticleEffect->m_pDef->IsViewModelEffect() ) { FormatViewModelAttachment( pPlayer, vecOrigin, true ); } } } else { // HACK_GETLOCALPLAYER_GUARD( "CParticleProperty::UpdateControlPoint" ); if ( pAnimating->GetAttachment( pPoint->iAttachmentPoint, attachmentToWorld ) ) { bValid = true; MatrixVectors( attachmentToWorld, &vecForward, &vecRight, &vecUp ); #ifdef _DEBUG float flTests[3] = {vecForward.Dot( vecRight ), vecRight.Dot( vecUp ), vecUp.Dot( vecForward )}; static float s_flMaxTest = 0.001f; Assert( fabs( flTests[0] ) + fabs( flTests[1] ) + fabs( flTests[2] ) < s_flMaxTest ); #endif MatrixPosition( attachmentToWorld, vecOrigin ); if ( pEffect->pParticleEffect->m_pDef->IsViewModelEffect() ) { HACK_GETLOCALPLAYER_GUARD( "CParticleProperty::UpdateControlPoint" ); FormatViewModelAttachment( NULL, vecOrigin, true ); } } } } if ( !bValid ) { static bool bWarned = false; if ( !bWarned ) { bWarned = true; DevWarning( "Attempted to attach particle effect %s to an unknown attachment on entity %s\n", pEffect->pParticleEffect->m_pDef->GetName(), pAnimating->GetClassname() ); } } if ( !bValid ) { AssertOnce( 0 ); return; } } break; case PATTACH_ABSORIGIN: case PATTACH_ABSORIGIN_FOLLOW: default: { vecOrigin = pPoint->hEntity->GetAbsOrigin() + pPoint->vecOriginOffset; pPoint->hEntity->GetVectors( &vecForward, &vecRight, &vecUp ); } break; case PATTACH_EYES_FOLLOW: { C_BaseEntity *pEnt = pPoint->hEntity; if ( !pEnt->IsPlayer() ) return; C_BasePlayer *pPlayer = assert_cast< C_BasePlayer* >( pEnt ); bool bValid = false; Assert( pPlayer ); if ( pPlayer ) { bValid = true; vecOrigin = pPlayer->EyePosition() + pPoint->vecOriginOffset; pPlayer->EyeVectors( &vecForward, &vecRight, &vecUp ); } if ( !bValid ) { AssertOnce( 0 ); return; } } break; case PATTACH_CUSTOMORIGIN_FOLLOW: { matrix3x4_t mat; MatrixMultiply( pPoint->hEntity->RenderableToWorldTransform(), pPoint->matOffset, mat ); MatrixVectors( mat, &vecForward, &vecRight, &vecUp ); vecOrigin = pPoint->hEntity->GetAbsOrigin() + pPoint->vecOriginOffset; } break; } pEffect->pParticleEffect->SetControlPointOrientation( pPoint->iControlPoint, vecForward, vecRight, vecUp ); pEffect->pParticleEffect->SetControlPointEntity( pPoint->iControlPoint, pPoint->hEntity ); pEffect->pParticleEffect->SetControlPoint( pPoint->iControlPoint, vecOrigin ); pEffect->pParticleEffect->SetSortOrigin( vecOrigin ); }
void CASW_Weapon_Chainsaw::AdjustChainsawPitch() { if ( !m_pChainsawAttackSound ) { if ( asw_chainsaw_debug.GetBool() ) { Msg( "No chainsaw attack sound, aborting\n" ); } return; } // Translated into the pitch values as represented in the soundscripts that would mean roughly that you // change the pitch value to randomly land between 85 and 90. (Pitch value 100 equals no change. Pitch value 50 is one octave lower.) // The pitch down should happen over 100 milliseconds. 400 ms later (half as second after the impact triggered the pitch down) // reset to the original pitch value over 250 ms. float flTransitionRate = 50.0f; // check for returning to normal pitch if ( ( gpGlobals->curtime - m_flLastHitTime ) > asw_chainsaw_pitch_return_delay.GetFloat() ) { m_flTargetChainsawPitch = 100.0f; flTransitionRate = asw_chainsaw_pitch_return_rate.GetFloat(); } else if ( m_flTargetChainsawPitch == 0.0f ) // just started attacking something { float flPitchMin = asw_chainsaw_pitch_target.GetFloat() - asw_chainsaw_pitch_range.GetFloat(); float flPitchMax = asw_chainsaw_pitch_target.GetFloat() + asw_chainsaw_pitch_range.GetFloat(); if ( asw_chainsaw_debug.GetBool() ) { Msg( "pitch min/max( %f %f )\n", flPitchMin, flPitchMax ); } m_flTargetChainsawPitch = RandomFloat( flPitchMin, flPitchMax ); flTransitionRate = asw_chainsaw_pitch_bite_rate.GetFloat(); #ifdef CLIENT_DLL if ( !( prediction && prediction->InPrediction() && !prediction->IsFirstTimePredicted() ) ) { // move this somewhere else.... ScreenShake_t shake; shake.command = SHAKE_STOP; shake.amplitude = 0; HACK_GETLOCALPLAYER_GUARD( "ASW_AdjustChainsawPitch" ); GetViewEffects()->Shake( shake ); shake.command = SHAKE_START; shake.amplitude = asw_chainsaw_shake_amplitude.GetFloat(); shake.frequency = asw_chainsaw_shake_frequency.GetFloat(); shake.duration = asw_chainsaw_shake_duration.GetFloat(); GetViewEffects()->Shake( shake ); } #endif } float flCurPitch = CSoundEnvelopeController::GetController().SoundGetPitch( m_pChainsawAttackSound ); if ( flCurPitch != m_flTargetChainsawPitch ) { if ( asw_chainsaw_debug.GetBool() ) { Msg( "Changing chainsaw pitch to %f transition rate %f\n", m_flTargetChainsawPitch, flTransitionRate ); } flCurPitch = Approach( m_flTargetChainsawPitch, flCurPitch, flTransitionRate * gpGlobals->curtime ); CSoundEnvelopeController::GetController().SoundChangePitch( m_pChainsawAttackSound, flCurPitch, 0.0f ); } }