Beispiel #1
0
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 );
	}
}
Beispiel #2
0
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() );
	}
}
Beispiel #3
0
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() );
	}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CTFSunroofProxy::OnBind( void *pArg )
{
	C_BaseEntity *pEntity = BindArgToEntity( pArg );
	C_BaseTFFourWheelVehicle* pVehicle = dynamic_cast<C_BaseTFFourWheelVehicle*>(pEntity);
	if( !pVehicle )
		return;

	if( pVehicle->GetPassengerCount() )
	{
		SetFloatResult(0.f);
	} 
	else
	{
		SetFloatResult(1.f);
	}
}
Beispiel #5
0
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() );
	}
}
Beispiel #6
0
void CIntProxy::OnBind( void *pC_BaseEntity )
{
	Assert( m_pSrc1 && m_pResult );

	MaterialVarType_t resultType;
	int vecSize;
	ComputeResultType( resultType, vecSize );

	switch( resultType )
	{
	case MATERIAL_VAR_TYPE_VECTOR:
		{
			Vector a;
			m_pSrc1->GetVecValue( a.Base(), vecSize );
			a[0] = ( float )( int )a[0];
			a[1] = ( float )( int )a[1];
			a[2] = ( float )( int )a[2];
			m_pResult->SetVecValue( a.Base(), vecSize );
		}
		break;

	case MATERIAL_VAR_TYPE_FLOAT:
		{
			float a = m_pSrc1->GetFloatValue();
			a = ( float )( int )a;
			SetFloatResult( a );
		}
		break;

	case MATERIAL_VAR_TYPE_INT:
		// don't do anything besides assignment!
		m_pResult->SetIntValue( m_pSrc1->GetIntValue() );
		break;
	}
}
Beispiel #7
0
void CEqualsProxy::OnBind( void *pC_BaseEntity )
{
	Assert( m_pSrc1 && m_pResult );

	MaterialVarType_t resultType;
	int vecSize;
	ComputeResultType( resultType, vecSize );

	switch( resultType )
	{
	case MATERIAL_VAR_TYPE_VECTOR:
		{
			Vector a;
			m_pSrc1->GetVecValue( a.Base(), vecSize );
			m_pResult->SetVecValue( a.Base(), vecSize );
		}
		break;

	case MATERIAL_VAR_TYPE_FLOAT:
		SetFloatResult( m_pSrc1->GetFloatValue() );
		break;

	case MATERIAL_VAR_TYPE_INT:
		m_pResult->SetIntValue( m_pSrc1->GetIntValue() );
		break;
	}
}
void CPlayerDamageTimeProxy::OnBind( void *pArg )
{
	C_BaseEntity *pEntity = BindArgToEntity( pArg );

	// NOTE: Player health max is not available on the server...
	C_BaseTFPlayer* pPlayer = dynamic_cast<C_BaseTFPlayer*>(pEntity);
	if (!pPlayer)
	{
		SetFloatResult( 10000 * m_Factor.GetFloat() );
		return;
	}

	Assert( m_pResult );
	float dt = gpGlobals->curtime - pPlayer->GetLastDamageTime();
	SetFloatResult( dt * m_Factor.GetFloat() );
}
Beispiel #9
0
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 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() );
	}
}
Beispiel #11
0
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() );
	}
}
void CPlayerHealthProxy::OnBind( void *pArg )
{
	// NOTE: Player health max is not available on the server...
	C_BaseEntity *pEntity = BindArgToEntity( pArg );
	C_BaseTFPlayer* pPlayer = dynamic_cast<C_BaseTFPlayer*>(pEntity);
	if (!pPlayer)
		return;

	Assert( m_pResult );
	SetFloatResult( pPlayer->HealthFraction() * m_Factor.GetFloat() );

	/*
	// Should we draw their health?
	// If he's not on our team we can't see it unless we're a command with "targetinginfo".
	if ( GetLocalTeam() != GetTeam() && !(local->HasNamedTechnology("targetinginfo") && IsLocalPlayerClass(TFCLASS_COMMANDO) ))
		return drawn;
	// Don't draw health bars above myself
	if ( local == this )
		return drawn;
	// Don't draw health bars over dead/dying player
	if ( GetHealth() <= 0 )
		return drawn;

	return drawn;
	*/
}
Beispiel #13
0
void CClampProxy::OnBind( void *pC_BaseEntity )
{
	Assert( m_pSrc1 && m_pResult );

	MaterialVarType_t resultType;
	int vecSize;
	ComputeResultType( resultType, vecSize );

	float flMin = m_Min.GetFloat();
	float flMax = m_Max.GetFloat();

	if (flMin > flMax)
	{
		float flTemp = flMin;
		flMin = flMax;
		flMax = flTemp;
	}

	switch( resultType )
	{
	case MATERIAL_VAR_TYPE_VECTOR:
		{
			Vector a;
			m_pSrc1->GetVecValue( a.Base(), vecSize );
			for (int i = 0; i < vecSize; ++i)
			{
				if (a[i] < flMin)
					a[i] = flMin;
				else if (a[i] > flMax)
					a[i] = flMax;
			}
			m_pResult->SetVecValue( a.Base(), vecSize );
		}
		break;

	case MATERIAL_VAR_TYPE_FLOAT:
		{
			float src = m_pSrc1->GetFloatValue();
			if (src < flMin)
				src = flMin;
			else if (src > flMax)
				src = flMax;
			SetFloatResult( src );
		}
		break;

	case MATERIAL_VAR_TYPE_INT:
		{
			int src = m_pSrc1->GetIntValue();
			if (src < flMin)
				src = flMin;
			else if (src > flMax)
				src = flMax;
			m_pResult->SetIntValue( src );
		}
		break;
	}
}
Beispiel #14
0
void CUniformNoiseProxy::OnBind( void *pC_BaseEntity )
{
	SetFloatResult( random->RandomFloat( m_flMinVal.GetFloat(), m_flMaxVal.GetFloat() ) );

	if ( ToolsEnabled() )
	{
		ToolFramework_RecordMaterialParams( GetMaterial() );
	}
}
Beispiel #15
0
void CAbsProxy::OnBind( void *pC_BaseEntity )
{	
	SetFloatResult( fabs(m_pSrc1->GetFloatValue( )) );

	if ( ToolsEnabled() )
	{
		ToolFramework_RecordMaterialParams( GetMaterial() );
	}
}
Beispiel #16
0
void CProxyHealth::OnBind( void *pC_BaseEntity )
{
    if (!pC_BaseEntity)
        return;

    C_BaseEntity *pEntity = BindArgToEntity( pC_BaseEntity );

    Assert( m_pResult );
    SetFloatResult( pEntity->HealthFraction() * m_Factor.GetFloat() );
}
Beispiel #17
0
void CDivideProxy::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 ); 
			VectorDivide( a, b, c );
			m_pResult->SetVecValue( c.Base(), vecSize );
		}
		break;

	case MATERIAL_VAR_TYPE_FLOAT:
		if (m_pSrc2->GetFloatValue() != 0)
		{
			SetFloatResult( m_pSrc1->GetFloatValue() / m_pSrc2->GetFloatValue() );
		}
		else
		{
			SetFloatResult( m_pSrc1->GetFloatValue() );
		}
		break;

	case MATERIAL_VAR_TYPE_INT:
		if (m_pSrc2->GetIntValue() != 0)
		{
			m_pResult->SetFloatValue( m_pSrc1->GetIntValue() / m_pSrc2->GetIntValue() );
		}
		else
		{
			m_pResult->SetFloatValue( m_pSrc1->GetIntValue() );
		}
		break;
	}
}
Beispiel #18
0
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 );
}
void CShieldPowerLevelProxy::OnBind( void *pRenderable )
{
	IClientRenderable *pRend = (IClientRenderable *)pRenderable;
	C_BaseEntity *pEntity = pRend->GetIClientUnknown()->GetBaseEntity();
	C_Shield *pShield = dynamic_cast<C_Shield*>(pEntity);
	if (!pShield)
		return;

	SetFloatResult( pShield->GetPowerLevel() );
}
Beispiel #20
0
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 CPlayerFortsTimerProxy::OnBind( void *pC_BaseEntity )
{
	if(HL2MPRules()->GetGameType() != GAME_FORTS)
		return;

	float flPhaseLimit = HL2MPRules()->GetLastFortsPhaseTime();
	flPhaseLimit += HL2MPRules()->IsFortsBuildPhase() ? mp_forts_buildtime.GetFloat() * 60 : mp_forts_fighttime.GetFloat() * 60;

	// Produit en croix
	//  ?  | curtime
	// 360 | phaselimit

	SetFloatResult( ceil( gpGlobals->curtime * m_RangeMax.GetFloat() / flPhaseLimit ));
}
Beispiel #22
0
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() );
	}
}
void CPlayerScoreProxy::OnBind( void *pArg )
{
	// Find the view angle between the player and this entity....
	C_BaseEntity *pEntity = BindArgToEntity( pArg );
	C_BaseTFPlayer* pPlayer = dynamic_cast<C_BaseTFPlayer*>(pEntity);
	if (!pPlayer)
		return;

	if ( !g_PR )
		return;

	int score = g_PR->Get_Score(pPlayer->index);

	Assert( m_pResult );
	SetFloatResult( score * m_Factor.GetFloat() );
}
Beispiel #25
0
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 CPlayerTeamMatchProxy::OnBind( void *pC_BaseEntity )
{
	if (!pC_BaseEntity)
		return;

	// Find the distance between the player and this entity....
	C_BaseEntity *pEntity = BindArgToEntity( pC_BaseEntity );
	C_BaseEntity* pPlayer = C_BasePlayer::GetLocalPlayer();
	if (!pPlayer)
		return;

	Assert( m_pResult );
	SetFloatResult( (pEntity->GetTeamNumber() == pPlayer->GetTeamNumber()) ? 1.0 : 0.0 );

	if ( ToolsEnabled() )
	{
		ToolFramework_RecordMaterialParams( GetMaterial() );
	}
}
Beispiel #27
0
void CSineProxy::OnBind( void *pC_BaseEntity )
{
	Assert( m_pResult );

	float flValue;
	float flSineTimeOffset = m_SineTimeOffset.GetFloat();
	float flSineMax = m_SineMax.GetFloat();
	float flSineMin = m_SineMin.GetFloat();
	float flSinePeriod = m_SinePeriod.GetFloat();
	if (flSinePeriod == 0)
		flSinePeriod = 1;

	// get a value in [0,1]
	flValue = ( sin( 2.0f * M_PI * (gpGlobals->curtime - flSineTimeOffset) / flSinePeriod ) * 0.5f ) + 0.5f;
	// get a value in [MIN,MAX]	
	flValue = ( flSineMax - flSineMin ) * flValue + flSineMin;
	
	SetFloatResult( flValue );
}
void CASWNightVisionSelfIllumProxy::OnBind( void *pC_BaseEntity )
{
	Assert( m_pResult );
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer || !pC_BaseEntity )
	{
		SetFloatResult( 0.0f );
		return;
	}

	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if ( !pMarine )
	{
		SetFloatResult( 0.0f );
		return;
	}

	if ( C_JaS_Alien_Controller::AutoList().Count() )
	{
		C_JaS_Alien_Controller *pAlienController = dynamic_cast<C_JaS_Alien_Controller *>( C_JaS_Alien_Controller::AutoList().Head()->GetEntity() );
		if ( pAlienController->m_hBuzzerOverride )
		{
			SetFloatResult( 255.0f );
			return;
		}
	}

	C_BaseCombatWeapon*	pExtraItem = pMarine->GetWeapon( 2 );
	if ( pExtraItem && pExtraItem->Classify() == CLASS_ASW_NIGHT_VISION )
	{
		C_ASW_Weapon_Night_Vision *pVision = assert_cast<CASW_Weapon_Night_Vision*>( pExtraItem );
		float flVisionAlpha = pVision->m_flVisionAlpha;
		if ( flVisionAlpha != 0.0f )
		{
			SetFloatResult( flVisionAlpha / 255.0f * asw_night_vision_self_illum_multiplier.GetFloat() );
			return;
		}
	}

	if ( pPlayer->IsSniperScopeActive() && g_bRenderingGlows )
	{
		SetFloatResult( asw_sniper_scope_self_illum_multiplier.GetFloat() );
		return;
	}

	SetFloatResult( 0.0f );
}
void CPlayerProximityProxy::OnBind( void *pC_BaseEntity )
{
	if (!pC_BaseEntity)
		return;

	// Find the distance between the player and this entity....
	C_BaseEntity *pEntity = BindArgToEntity( pC_BaseEntity );
	C_BaseEntity* pPlayer = C_BasePlayer::GetLocalPlayer();
	if (!pPlayer || !pEntity) //<-- GE_DLL
		return;

	Vector delta;
	VectorSubtract( pEntity->WorldSpaceCenter(), pPlayer->WorldSpaceCenter(), delta );

	Assert( m_pResult );
	SetFloatResult( delta.Length() * m_Factor );

	if ( ToolsEnabled() )
	{
		ToolFramework_RecordMaterialParams( GetMaterial() );
	}
}
Beispiel #30
0
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 );
}