diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/tf2/teammaterialproxy.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/tf2/teammaterialproxy.cpp')
| -rw-r--r-- | game/client/tf2/teammaterialproxy.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/game/client/tf2/teammaterialproxy.cpp b/game/client/tf2/teammaterialproxy.cpp new file mode 100644 index 0000000..9fcc923 --- /dev/null +++ b/game/client/tf2/teammaterialproxy.cpp @@ -0,0 +1,71 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "cbase.h" +#include "proxyentity.h" +#include "materialsystem/imaterial.h" +#include "materialsystem/imaterialvar.h" +#include "c_team.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +// $sineVar : name of variable that controls the alpha level (float) +class CTeamMaterialProxy : public CEntityMaterialProxy +{ +public: + CTeamMaterialProxy(); + virtual ~CTeamMaterialProxy(); + virtual bool Init( IMaterial *pMaterial, KeyValues* pKeyValues ); + virtual void OnBind( C_BaseEntity *pEnt ); + +private: + IMaterialVar* m_FrameVar; +}; + + +//----------------------------------------------------------------------------- +// Constructor, destructor +//----------------------------------------------------------------------------- + +CTeamMaterialProxy::CTeamMaterialProxy() +{ + m_FrameVar = 0; +} + +CTeamMaterialProxy::~CTeamMaterialProxy() +{ +} + + +//----------------------------------------------------------------------------- +// Init baby... +//----------------------------------------------------------------------------- +bool CTeamMaterialProxy::Init( IMaterial *pMaterial, KeyValues* pKeyValues ) +{ + bool foundVar; + m_FrameVar = pMaterial->FindVar( "$frame", &foundVar, false ); + if( !foundVar ) + m_FrameVar = 0; + return true; +} + +//----------------------------------------------------------------------------- +// Set the appropriate texture... +//----------------------------------------------------------------------------- +void CTeamMaterialProxy::OnBind( C_BaseEntity *pEnt ) +{ + if( !m_FrameVar ) + return; + + int team = pEnt->GetRenderTeamNumber(); + team--; + + // Use that as an animated frame number + m_FrameVar->SetIntValue( team ); +} + +EXPOSE_INTERFACE( CTeamMaterialProxy, IMaterialProxy, "TeamTexture" IMATERIAL_PROXY_INTERFACE_VERSION ); |