void CSubtractProxy::OnBind( void *pC_BaseEntity ) { Assert( m_pSrc1 && m_pSrc2 && m_pResult ); MaterialVarType_t resultType; int vecSize; ComputeResultType( resultType, vecSize ); switch( resultType ) { case MATERIAL_VAR_TYPE_VECTOR: { Vector a, b, c; m_pSrc1->GetVecValue( a.Base(), vecSize ); m_pSrc2->GetVecValue( b.Base(), vecSize ); VectorSubtract( a, b, c ); m_pResult->SetVecValue( c.Base(), vecSize ); } break; case MATERIAL_VAR_TYPE_FLOAT: SetFloatResult( m_pSrc1->GetFloatValue() - m_pSrc2->GetFloatValue() ); break; case MATERIAL_VAR_TYPE_INT: m_pResult->SetFloatValue( m_pSrc1->GetIntValue() - m_pSrc2->GetIntValue() ); break; } if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
//----------------------------------------------------------------------------- // Recording //----------------------------------------------------------------------------- static inline void RecordPhysicsProp( const Vector& start, const QAngle &angles, const Vector& vel, int nModelIndex, int flags, int nSkin, int nEffects ) { if ( !ToolsEnabled() ) return; if ( clienttools->IsInRecordingMode() ) { const model_t* pModel = (nModelIndex != 0) ? modelinfo->GetModel( nModelIndex ) : NULL; const char *pModelName = pModel ? modelinfo->GetModelName( pModel ) : ""; KeyValues *msg = new KeyValues( "TempEntity" ); msg->SetInt( "te", TE_PHYSICS_PROP ); msg->SetString( "name", "TE_PhysicsProp" ); msg->SetFloat( "time", gpGlobals->curtime ); msg->SetFloat( "originx", start.x ); msg->SetFloat( "originy", start.y ); msg->SetFloat( "originz", start.z ); msg->SetFloat( "anglesx", angles.x ); msg->SetFloat( "anglesy", angles.y ); msg->SetFloat( "anglesz", angles.z ); msg->SetFloat( "velx", vel.x ); msg->SetFloat( "vely", vel.y ); msg->SetFloat( "velz", vel.z ); msg->SetString( "model", pModelName ); msg->SetInt( "breakmodel", flags ); msg->SetInt( "skin", nSkin ); msg->SetInt( "effects", nEffects ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
//----------------------------------------------------------------------------- // Recording //----------------------------------------------------------------------------- static inline void RecordBloodSprite( const Vector &start, const Vector &direction, int r, int g, int b, int a, int nSprayModelIndex, int nDropModelIndex, int size ) { if ( !ToolsEnabled() ) return; if ( clienttools->IsInRecordingMode() ) { Color clr( r, g, b, a ); const model_t* pSprayModel = (nSprayModelIndex != 0) ? modelinfo->GetModel( nSprayModelIndex ) : NULL; const model_t* pDropModel = (nDropModelIndex != 0) ? modelinfo->GetModel( nDropModelIndex ) : NULL; const char *pSprayModelName = pSprayModel ? modelinfo->GetModelName( pSprayModel ) : ""; const char *pDropModelName = pDropModel ? modelinfo->GetModelName( pDropModel ) : ""; KeyValues *msg = new KeyValues( "TempEntity" ); msg->SetInt( "te", TE_BLOOD_SPRITE ); msg->SetString( "name", "TE_BloodSprite" ); msg->SetFloat( "time", gpGlobals->curtime ); msg->SetFloat( "originx", start.x ); msg->SetFloat( "originy", start.y ); msg->SetFloat( "originz", start.z ); msg->SetFloat( "directionx", direction.x ); msg->SetFloat( "directiony", direction.y ); msg->SetFloat( "directionz", direction.z ); msg->SetColor( "color", clr ); msg->SetString( "spraymodel", pSprayModelName ); msg->SetString( "dropmodel", pDropModelName ); msg->SetInt( "size", size ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
void CWrapMinMaxProxy::OnBind( void *pC_BaseEntity ) { Assert( m_pSrc1 && m_pResult ); if ( m_flMaxVal.GetFloat() <= m_flMinVal.GetFloat() ) // Bad input, just return the min { SetFloatResult( m_flMinVal.GetFloat() ); } else { float flResult = ( m_pSrc1->GetFloatValue() - m_flMinVal.GetFloat() ) / ( m_flMaxVal.GetFloat() - m_flMinVal.GetFloat() ); if ( flResult >= 0.0f ) { flResult -= ( float )( int )flResult; } else // Negative { flResult -= ( float )( ( ( int )flResult ) - 1 ); } flResult *= ( m_flMaxVal.GetFloat() - m_flMinVal.GetFloat() ); flResult += m_flMinVal.GetFloat(); SetFloatResult( flResult ); } if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
//----------------------------------------------------------------------------- // Recording //----------------------------------------------------------------------------- static inline void RecordMuzzleFlash( const Vector &start, const QAngle &angles, float scale, int type ) { if ( !ToolsEnabled() ) return; if ( clienttools->IsInRecordingMode() ) { KeyValues *msg = new KeyValues( "TempEntity" ); msg->SetInt( "te", TE_MUZZLE_FLASH ); msg->SetString( "name", "TE_MuzzleFlash" ); msg->SetFloat( "time", gpGlobals->curtime ); msg->SetFloat( "originx", start.x ); msg->SetFloat( "originy", start.y ); msg->SetFloat( "originz", start.z ); msg->SetFloat( "anglesx", angles.x ); msg->SetFloat( "anglesy", angles.y ); msg->SetFloat( "anglesz", angles.z ); msg->SetFloat( "scale", scale ); msg->SetInt( "type", type ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
void CPlayerViewProxy::OnBind( void *pC_BaseEntity ) { if (!pC_BaseEntity) return; // Find the view angle between the player and this entity.... C_BaseEntity *pEntity = BindArgToEntity( pC_BaseEntity ); C_BaseEntity* pPlayer = C_BasePlayer::GetLocalPlayer(); if (!pPlayer) return; Vector delta; VectorSubtract( pEntity->WorldSpaceCenter(), pPlayer->WorldSpaceCenter(), delta ); VectorNormalize( delta ); Vector forward; AngleVectors( pPlayer->GetAbsAngles(), &forward ); Assert( m_pResult ); SetFloatResult( DotProduct( forward, delta ) * m_Factor ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
//----------------------------------------------------------------------------- // Recording //----------------------------------------------------------------------------- static inline void RecordDecal( const Vector &pos, const Vector &start, int entity, int hitbox, int index ) { if ( !ToolsEnabled() ) return; if ( clienttools->IsInRecordingMode() ) { // FIXME: Can't record on entities yet if ( entity != 0 ) return; KeyValues *msg = new KeyValues( "TempEntity" ); msg->SetInt( "te", TE_DECAL ); msg->SetString( "name", "TE_Decal" ); msg->SetFloat( "time", gpGlobals->curtime ); msg->SetFloat( "originx", pos.x ); msg->SetFloat( "originy", pos.y ); msg->SetFloat( "originz", pos.z ); msg->SetFloat( "startx", start.x ); msg->SetFloat( "starty", start.y ); msg->SetFloat( "startz", start.z ); msg->SetInt( "hitbox", hitbox ); msg->SetString( "decalname", effects->Draw_DecalNameFromIndex( index ) ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
void CGaussianNoiseProxy::OnBind( void *pC_BaseEntity ) { float flMean = m_Mean.GetFloat(); float flStdDev = m_StdDev.GetFloat(); float flVal = randomgaussian->RandomFloat( flMean, flStdDev ); float flMaxVal = m_flMaxVal.GetFloat(); float flMinVal = m_flMinVal.GetFloat(); if (flMinVal > flMaxVal) { float flTemp = flMinVal; flMinVal = flMaxVal; flMaxVal = flTemp; } // clamp if (flVal < flMinVal) flVal = flMinVal; else if ( flVal > flMaxVal ) flVal = flMaxVal; SetFloatResult( flVal ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
void CExponentialProxy::OnBind( void *pC_BaseEntity ) { float flVal = m_Scale.GetFloat() * exp(m_pSrc1->GetFloatValue( ) + m_Offset.GetFloat()); float flMaxVal = m_flMaxVal.GetFloat(); float flMinVal = m_flMinVal.GetFloat(); if (flMinVal > flMaxVal) { float flTemp = flMinVal; flMinVal = flMaxVal; flMaxVal = flTemp; } // clamp if (flVal < flMinVal) flVal = flMinVal; else if ( flVal > flMaxVal ) flVal = flMaxVal; SetFloatResult( flVal ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
//----------------------------------------------------------------------------- // Recording //----------------------------------------------------------------------------- static inline void RecordSprite( const Vector& start, int nModelIndex, float flScale, int nBrightness ) { if ( !ToolsEnabled() ) return; if ( clienttools->IsInRecordingMode() ) { const model_t* pModel = (nModelIndex != 0) ? modelinfo->GetModel( nModelIndex ) : NULL; const char *pModelName = pModel ? modelinfo->GetModelName( pModel ) : ""; KeyValues *msg = new KeyValues( "TempEntity" ); msg->SetInt( "te", TE_SPRITE_SINGLE ); msg->SetString( "name", "TE_Sprite" ); msg->SetFloat( "time", gpGlobals->curtime ); msg->SetFloat( "originx", start.x ); msg->SetFloat( "originy", start.y ); msg->SetFloat( "originz", start.z ); msg->SetString( "model", pModelName ); msg->SetFloat( "scale", flScale ); msg->SetInt( "brightness", nBrightness ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
//----------------------------------------------------------------------------- // Recording //----------------------------------------------------------------------------- void C_TEExplosion::RecordExplosion( ) { if ( !ToolsEnabled() ) return; if ( clienttools->IsInRecordingMode() ) { const model_t* pModel = (m_nModelIndex != 0) ? modelinfo->GetModel( m_nModelIndex ) : NULL; const char *pModelName = pModel ? modelinfo->GetModelName( pModel ) : ""; KeyValues *msg = new KeyValues( "TempEntity" ); msg->SetInt( "te", TE_EXPLOSION ); msg->SetString( "name", "TE_Explosion" ); msg->SetFloat( "time", gpGlobals->curtime ); msg->SetFloat( "originx", m_vecOrigin.x ); msg->SetFloat( "originy", m_vecOrigin.y ); msg->SetFloat( "originz", m_vecOrigin.z ); msg->SetFloat( "directionx", m_vecNormal.x ); msg->SetFloat( "directiony", m_vecNormal.y ); msg->SetFloat( "directionz", m_vecNormal.z ); msg->SetString( "model", pModelName ); msg->SetFloat( "scale", m_fScale ); msg->SetInt( "framerate", m_nFrameRate ); msg->SetInt( "flags", m_nFlags ); msg->SetInt( "materialtype", m_chMaterialType ); msg->SetInt( "radius", m_nRadius ); msg->SetInt( "magnitude", m_nMagnitude ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
//----------------------------------------------------------------------------- // tool recording //----------------------------------------------------------------------------- void C_BaseCombatWeapon::GetToolRecordingState( KeyValues *msg ) { if ( !ToolsEnabled() ) return; int nModelIndex = GetModelIndex(); int nWorldModelIndex = GetWorldModelIndex(); if ( nModelIndex != nWorldModelIndex ) { SetModelIndex( nWorldModelIndex ); } BaseClass::GetToolRecordingState( msg ); if ( m_iState == WEAPON_NOT_CARRIED ) { BaseEntityRecordingState_t *pBaseEntity = (BaseEntityRecordingState_t*)msg->GetPtr( "baseentity" ); pBaseEntity->m_nOwner = -1; } else { msg->SetInt( "worldmodel", 1 ); if ( m_iState == WEAPON_IS_ACTIVE ) { BaseEntityRecordingState_t *pBaseEntity = (BaseEntityRecordingState_t*)msg->GetPtr( "baseentity" ); pBaseEntity->m_bVisible = true; } } if ( nModelIndex != nWorldModelIndex ) { SetModelIndex( nModelIndex ); } }
//----------------------------------------------------------------------------- // Recording //----------------------------------------------------------------------------- static inline void RecordSparks( const Vector &start, int nMagnitude, int nTrailLength, const Vector &direction ) { if ( !ToolsEnabled() ) return; if ( clienttools->IsInRecordingMode() ) { KeyValues *msg = new KeyValues( "TempEntity" ); msg->SetInt( "te", TE_SPARKS ); msg->SetString( "name", "TE_Sparks" ); msg->SetFloat( "time", gpGlobals->curtime ); msg->SetFloat( "originx", start.x ); msg->SetFloat( "originy", start.y ); msg->SetFloat( "originz", start.z ); msg->SetFloat( "directionx", direction.x ); msg->SetFloat( "directiony", direction.y ); msg->SetFloat( "directionz", direction.z ); msg->SetInt( "magnitude", nMagnitude ); msg->SetInt( "traillength", nTrailLength ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
void CMaterialModifyProxy::OnBind( void *pEntity ) { // Get the modified material vars from the entity input IClientRenderable *pRend = (IClientRenderable *)pEntity; if ( pRend ) { C_BaseEntity *pBaseEntity = pRend->GetIClientUnknown()->GetBaseEntity(); if ( pBaseEntity ) { if( debug_materialmodifycontrol_client.GetBool() ) { // DevMsg( 1, "%s\n", pBaseEntity->GetDebugName() ); } int numChildren = 0; bool gotOne = false; for ( C_BaseEntity *pChild = pBaseEntity->FirstMoveChild(); pChild; pChild = pChild->NextMovePeer() ) { numChildren++; C_MaterialModifyControl *pControl = dynamic_cast<C_MaterialModifyControl*>( pChild ); if ( !pControl ) continue; if( debug_materialmodifycontrol_client.GetBool() ) { // DevMsg( 1, "pControl: 0x%p\n", pControl ); } switch( pControl->GetModifyMode() ) { case MATERIAL_MODIFY_MODE_NONE: break; case MATERIAL_MODIFY_MODE_SETVAR: gotOne = true; OnBindSetVar( pControl ); break; case MATERIAL_MODIFY_MODE_ANIM_SEQUENCE: OnBindAnimatedTexture( pControl ); break; case MATERIAL_MODIFY_MODE_FLOAT_LERP: OnBindFloatLerp( pControl ); break; default: Assert( 0 ); break; } } if( gotOne ) { // DevMsg( 1, "numChildren: %d\n", numChildren ); } } } if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
void CUniformNoiseProxy::OnBind( void *pC_BaseEntity ) { SetFloatResult( random->RandomFloat( m_flMinVal.GetFloat(), m_flMaxVal.GetFloat() ) ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
void CAbsProxy::OnBind( void *pC_BaseEntity ) { SetFloatResult( fabs(m_pSrc1->GetFloatValue( )) ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
void CLessOrEqualProxy::OnBind( void *pC_BaseEntity ) { Assert( m_pSrc1 && m_pSrc2 && m_pLessVar && m_pGreaterVar && m_pResult ); IMaterialVar *pSourceVar; if (m_pSrc1->GetFloatValue() <= m_pSrc2->GetFloatValue()) { pSourceVar = m_pLessVar; } else { pSourceVar = m_pGreaterVar; } int vecSize = 0; MaterialVarType_t resultType = m_pResult->GetType(); if (resultType == MATERIAL_VAR_TYPE_VECTOR) { if (m_ResultVecComp >= 0) resultType = MATERIAL_VAR_TYPE_FLOAT; vecSize = m_pResult->VectorSize(); } else if (resultType == MATERIAL_VAR_TYPE_UNDEFINED) { resultType = pSourceVar->GetType(); if (resultType == MATERIAL_VAR_TYPE_VECTOR) { vecSize = pSourceVar->VectorSize(); } } switch( resultType ) { case MATERIAL_VAR_TYPE_VECTOR: { Vector src; pSourceVar->GetVecValue( src.Base(), vecSize ); m_pResult->SetVecValue( src.Base(), vecSize ); } break; case MATERIAL_VAR_TYPE_FLOAT: SetFloatResult( pSourceVar->GetFloatValue() ); break; case MATERIAL_VAR_TYPE_INT: m_pResult->SetFloatValue( pSourceVar->GetIntValue() ); break; } if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
void CSelectFirstIfNonZeroProxy::OnBind( void *pC_BaseEntity ) { Assert( m_pSrc1 && m_pSrc2 && m_pResult ); MaterialVarType_t resultType; int vecSize; ComputeResultType( resultType, vecSize ); switch( resultType ) { case MATERIAL_VAR_TYPE_VECTOR: { Vector a, b; m_pSrc1->GetVecValue( a.Base(), vecSize ); m_pSrc2->GetVecValue( b.Base(), vecSize ); if ( !a.IsZero() ) { m_pResult->SetVecValue( a.Base(), vecSize ); } else { m_pResult->SetVecValue( b.Base(), vecSize ); } } break; case MATERIAL_VAR_TYPE_FLOAT: if ( m_pSrc1->GetFloatValue() ) { SetFloatResult( m_pSrc1->GetFloatValue() ); } else { SetFloatResult( m_pSrc2->GetFloatValue() ); } break; case MATERIAL_VAR_TYPE_INT: if ( m_pSrc1->GetIntValue() ) { m_pResult->SetFloatValue( m_pSrc1->GetIntValue() ); } else { m_pResult->SetFloatValue( m_pSrc2->GetIntValue() ); } break; } if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
//----------------------------------------------------------------------------- // Helper class to indicate ownership of effects //----------------------------------------------------------------------------- CRecordEffectOwner::CRecordEffectOwner( C_BaseEntity *pEntity, bool bIsViewModel ) { m_bToolsEnabled = ToolsEnabled() && clienttools->IsInRecordingMode(); if ( m_bToolsEnabled ) { KeyValues *msg = new KeyValues( "EffectsOwner" ); msg->SetInt( "viewModel", bIsViewModel ); ToolFramework_PostToolMessage( pEntity ? pEntity->GetToolHandle() : HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
CBaseParticleEntity::~CBaseParticleEntity( void ) { #if defined( CLIENT_DLL ) if ( ToolsEnabled() && ( m_nToolParticleEffectId != TOOLPARTICLESYSTEMID_INVALID ) && clienttools->IsInRecordingMode() ) { KeyValues *msg = new KeyValues( "ParticleSystem_Destroy" ); msg->SetInt( "id", m_nToolParticleEffectId ); m_nToolParticleEffectId = TOOLPARTICLESYSTEMID_INVALID; } #endif }
void CClientTools::OnEntityCreated( CBaseEntity *pEntity ) { if ( !ToolsEnabled() ) return; HTOOLHANDLE h = AttachToEntity( pEntity ); // Send deletion message to tool interface KeyValues *kv = new KeyValues( "created" ); kv->SetPtr( "esr", ( void* )pEntity ); ToolFramework_PostToolMessage( h, kv ); kv->deleteThis(); }
void CTextureScrollMaterialProxy::OnBind( void *pC_BaseEntity ) { if( !m_pTextureScrollVar ) { return; } float rate, angle, scale; // set default values if these variables don't exist. rate = m_TextureScrollRate.GetFloat(); angle = m_TextureScrollAngle.GetFloat(); scale = m_TextureScale.GetFloat(); float sOffset, tOffset; sOffset = gpGlobals->curtime * cos( angle * ( M_PI / 180.0f ) ) * rate; tOffset = gpGlobals->curtime * sin( angle * ( M_PI / 180.0f ) ) * rate; // make sure that we are positive if( sOffset < 0.0f ) { sOffset += 1.0f + -( int )sOffset; } if( tOffset < 0.0f ) { tOffset += 1.0f + -( int )tOffset; } // make sure that we are in a [0,1] range sOffset = sOffset - ( int )sOffset; tOffset = tOffset - ( int )tOffset; if (m_pTextureScrollVar->GetType() == MATERIAL_VAR_TYPE_MATRIX) { VMatrix mat( scale, 0.0f, 0.0f, sOffset, 0.0f, scale, 0.0f, tOffset, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f ); m_pTextureScrollVar->SetMatrixValue( mat ); } else { m_pTextureScrollVar->SetVecValue( sOffset, tOffset, 0.0f ); } if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
//----------------------------------------------------------------------------- // Record effects //----------------------------------------------------------------------------- static void RecordEffect( const char *pEffectName, const CEffectData &data ) { if ( !ToolsEnabled() ) return; if ( clienttools->IsInRecordingMode() && ( (data.m_fFlags & EFFECTDATA_NO_RECORD) == 0 ) ) { KeyValues *msg = new KeyValues( "TempEntity" ); const char *pSurfacePropName = physprops->GetPropName( data.m_nSurfaceProp ); char pName[1024]; Q_snprintf( pName, sizeof(pName), "TE_DispatchEffect %s %s", pEffectName, pSurfacePropName ); msg->SetInt( "te", TE_DISPATCH_EFFECT ); msg->SetString( "name", pName ); msg->SetFloat( "time", gpGlobals->curtime ); msg->SetFloat( "originx", data.m_vOrigin.x ); msg->SetFloat( "originy", data.m_vOrigin.y ); msg->SetFloat( "originz", data.m_vOrigin.z ); msg->SetFloat( "startx", data.m_vStart.x ); msg->SetFloat( "starty", data.m_vStart.y ); msg->SetFloat( "startz", data.m_vStart.z ); msg->SetFloat( "normalx", data.m_vNormal.x ); msg->SetFloat( "normaly", data.m_vNormal.y ); msg->SetFloat( "normalz", data.m_vNormal.z ); msg->SetFloat( "anglesx", data.m_vAngles.x ); msg->SetFloat( "anglesy", data.m_vAngles.y ); msg->SetFloat( "anglesz", data.m_vAngles.z ); msg->SetInt( "flags", data.m_fFlags ); msg->SetFloat( "scale", data.m_flScale ); msg->SetFloat( "magnitude", data.m_flMagnitude ); msg->SetFloat( "radius", data.m_flRadius ); msg->SetString( "surfaceprop", pSurfacePropName ); msg->SetInt( "color", data.m_nColor ); msg->SetInt( "damagetype", data.m_nDamageType ); msg->SetInt( "hitbox", data.m_nHitBox ); msg->SetString( "effectname", pEffectName ); // FIXME: Need to write the attachment name here msg->SetInt( "attachmentindex", data.m_nAttachmentIndex ); // NOTE: Ptrs are our way of indicating it's an entindex msg->SetPtr( "entindex", (void*)data.entindex() ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
void CProxySniperRifleCharge::OnBind( void *pC_BaseEntity ) { Assert( m_pResult ); C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer(); if ( GetSpectatorTarget() != 0 && GetSpectatorMode() == OBS_MODE_IN_EYE ) { pPlayer = (C_TFPlayer *)UTIL_PlayerByIndex( GetSpectatorTarget() ); } if ( pPlayer ) { CTFSniperRifle *pWeapon = assert_cast<CTFSniperRifle*>(pPlayer->GetActiveTFWeapon()); if ( pWeapon ) { float flChargeValue = ( ( 1.0 - pWeapon->GetHUDDamagePerc() ) * 0.8 ) + 0.6; VMatrix mat, temp; Vector2D center( 0.5, 0.5 ); MatrixBuildTranslation( mat, -center.x, -center.y, 0.0f ); // scale { Vector2D scale( 1.0f, 0.25f ); MatrixBuildScale( temp, scale.x, scale.y, 1.0f ); MatrixMultiply( temp, mat, mat ); } MatrixBuildTranslation( temp, center.x, center.y, 0.0f ); MatrixMultiply( temp, mat, mat ); // translation { Vector2D translation( 0.0f, flChargeValue ); MatrixBuildTranslation( temp, translation.x, translation.y, 0.0f ); MatrixMultiply( temp, mat, mat ); } m_pResult->SetMatrixValue( mat ); } } if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CSprite::GetToolRecordingState( KeyValues *msg ) { if ( !ToolsEnabled() ) return; VPROF_BUDGET( "CSprite::GetToolRecordingState", VPROF_BUDGETGROUP_TOOLS ); BaseClass::GetToolRecordingState( msg ); // Use attachment point if ( m_hAttachedToEntity ) { C_BaseEntity *ent = m_hAttachedToEntity->GetBaseEntity(); if ( ent ) { BaseEntityRecordingState_t *pState = (BaseEntityRecordingState_t*)msg->GetPtr( "baseentity" ); // override position if we're driven by an attachment QAngle temp; pState->m_vecRenderOrigin = GetAbsOrigin(); ent->GetAttachment( m_nAttachment, pState->m_vecRenderOrigin, temp ); // override viewmodel if we're driven by an attachment bool bViewModel = ToBaseViewModel( ent ) != NULL; msg->SetInt( "viewmodel", bViewModel ); } } float renderscale = GetRenderScale(); if ( m_bWorldSpaceScale ) { CEngineSprite *psprite = ( CEngineSprite * )modelinfo->GetModelExtraData( GetModel() ); float flMinSize = MIN( psprite->GetWidth(), psprite->GetHeight() ); renderscale /= flMinSize; } color24 c = GetRenderColor(); // sprite params static SpriteRecordingState_t state; state.m_flRenderScale = renderscale; state.m_flFrame = m_flFrame; state.m_flProxyRadius = m_flGlowProxySize; state.m_nRenderMode = GetRenderMode(); state.m_nRenderFX = GetRenderFX() ? true : false; state.m_Color.SetColor( c.r, c.g, c.b, GetRenderBrightness() ); msg->SetPtr( "sprite", &state ); }
void CLinearRampProxy::OnBind( void *pC_BaseEntity ) { Assert( m_pResult ); float flValue; // get a value in [0,1] flValue = m_Rate.GetFloat() * gpGlobals->curtime + m_InitialValue.GetFloat(); SetFloatResult( flValue ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
void CPlayerSpeedProxy::OnBind( void *pC_BaseEntity ) { // Find the player speed.... C_BaseEntity* pPlayer = C_BasePlayer::GetLocalPlayer(); if (!pPlayer) return; Assert( m_pResult ); SetFloatResult( pPlayer->GetLocalVelocity().Length() * m_Factor ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
//----------------------------------------------------------------------------- // Helper class to deal with floating point inputs //----------------------------------------------------------------------------- void CEntityMaterialProxy::OnBind( void *pRenderable ) { if( !pRenderable ) return; IClientRenderable *pRend = ( IClientRenderable* )pRenderable; C_BaseEntity *pEnt = pRend->GetIClientUnknown()->GetBaseEntity(); if ( pEnt ) { OnBind( pEnt ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } } }
void CObjectPowerProxy::OnBind( void *pRenderable ) { // Find the view angle between the player and this entity.... IClientRenderable *pRend = (IClientRenderable *)pRenderable; C_BaseEntity *pEntity = pRend->GetIClientUnknown()->GetBaseEntity(); C_BaseObject *pObject = dynamic_cast<C_BaseObject*>(pEntity); if (!pObject) return; SetFloatResult( m_Factor.GetFloat() ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
void CEntityRandomProxy::OnBind( void *pC_BaseEntity ) { // Find the view angle between the player and this entity.... if (!pC_BaseEntity) return; // Find the view angle between the player and this entity.... C_BaseEntity *pEntity = BindArgToEntity( pC_BaseEntity ); Assert( m_pResult ); m_pResult->SetFloatValue( pEntity->ProxyRandomValue() * m_Factor.GetFloat() ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }