From 39ed87570bdb2f86969d4be821c94b722dc71179 Mon Sep 17 00:00:00 2001 From: Joe Ludwig Date: Wed, 26 Jun 2013 15:22:04 -0700 Subject: First version of the SOurce SDK 2013 --- mp/src/game/client/AnimateSpecificTextureProxy.cpp | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 mp/src/game/client/AnimateSpecificTextureProxy.cpp (limited to 'mp/src/game/client/AnimateSpecificTextureProxy.cpp') diff --git a/mp/src/game/client/AnimateSpecificTextureProxy.cpp b/mp/src/game/client/AnimateSpecificTextureProxy.cpp new file mode 100644 index 00000000..f20f716f --- /dev/null +++ b/mp/src/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 + +// 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 -- cgit v1.2.3