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/AnimateSpecificTextureProxy.cpp | |
| download | archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip | |
Diffstat (limited to 'game/client/AnimateSpecificTextureProxy.cpp')
| -rw-r--r-- | game/client/AnimateSpecificTextureProxy.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/game/client/AnimateSpecificTextureProxy.cpp b/game/client/AnimateSpecificTextureProxy.cpp new file mode 100644 index 0000000..e4fe742 --- /dev/null +++ b/game/client/AnimateSpecificTextureProxy.cpp @@ -0,0 +1,53 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Acts exactly like "AnimatedTexture", but ONLY if the texture +// it's working on matches the desired texture to work on. +// +// This assumes that some other proxy will be switching out the textures. +// +// $NoKeywords: $ +//=============================================================================// +#include "cbase.h" +#include "materialsystem/imaterialproxy.h" +#include "materialsystem/imaterialvar.h" +#include "materialsystem/imaterial.h" +#include "materialsystem/itexture.h" +#include "baseanimatedtextureproxy.h" +#include "utlstring.h" +#include <KeyValues.h> + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +class CAnimateSpecificTexture : public CBaseAnimatedTextureProxy +{ +private: + CUtlString m_OnlyAnimateOnTexture; +public: + virtual float GetAnimationStartTime( void* pBaseEntity ) { return 0; } + virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues ); + virtual void OnBind( void *pC_BaseEntity ); + virtual void Release( void ) { delete this; } +}; + +bool CAnimateSpecificTexture::Init( IMaterial *pMaterial, KeyValues *pKeyValues ) +{ + char const* pszAnimateOnTexture = pKeyValues->GetString( "onlyAnimateOnTexture" ); + if( !pszAnimateOnTexture ) + return false; + + m_OnlyAnimateOnTexture.Set( pszAnimateOnTexture ); + + return CBaseAnimatedTextureProxy::Init( pMaterial, pKeyValues ); +} + +void CAnimateSpecificTexture::OnBind( void *pC_BaseEntity ) +{ + if( FStrEq( m_AnimatedTextureVar->GetTextureValue()->GetName(), m_OnlyAnimateOnTexture ) ) + { + CBaseAnimatedTextureProxy::OnBind( pC_BaseEntity ); + } + //else do nothing +} + +EXPOSE_INTERFACE( CAnimateSpecificTexture, IMaterialProxy, "AnimateSpecificTexture" IMATERIAL_PROXY_INTERFACE_VERSION );
\ No newline at end of file |