Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Acts exactly like "AnimatedTexture", but ONLY if the texture
  4. // it's working on matches the desired texture to work on.
  5. //
  6. // This assumes that some other proxy will be switching out the textures.
  7. //
  8. // $NoKeywords: $
  9. //=============================================================================//
  10. #include "cbase.h"
  11. #include "materialsystem/imaterialproxy.h"
  12. #include "materialsystem/imaterialvar.h"
  13. #include "materialsystem/imaterial.h"
  14. #include "materialsystem/itexture.h"
  15. #include "baseanimatedtextureproxy.h"
  16. #include "utlstring.h"
  17. #include <KeyValues.h>
  18. // memdbgon must be the last include file in a .cpp file!!!
  19. #include "tier0/memdbgon.h"
  20. class CAnimateSpecificTexture : public CBaseAnimatedTextureProxy
  21. {
  22. private:
  23. CUtlString m_OnlyAnimateOnTexture;
  24. public:
  25. virtual float GetAnimationStartTime( void* pBaseEntity ) { return 0; }
  26. virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
  27. virtual void OnBind( void *pC_BaseEntity );
  28. virtual void Release( void ) { delete this; }
  29. };
  30. bool CAnimateSpecificTexture::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
  31. {
  32. char const* pszAnimateOnTexture = pKeyValues->GetString( "onlyAnimateOnTexture" );
  33. if( !pszAnimateOnTexture )
  34. return false;
  35. m_OnlyAnimateOnTexture.Set( pszAnimateOnTexture );
  36. return CBaseAnimatedTextureProxy::Init( pMaterial, pKeyValues );
  37. }
  38. void CAnimateSpecificTexture::OnBind( void *pC_BaseEntity )
  39. {
  40. if( FStrEq( m_AnimatedTextureVar->GetTextureValue()->GetName(), m_OnlyAnimateOnTexture ) )
  41. {
  42. CBaseAnimatedTextureProxy::OnBind( pC_BaseEntity );
  43. }
  44. //else do nothing
  45. }
  46. EXPOSE_INTERFACE( CAnimateSpecificTexture, IMaterialProxy, "AnimateSpecificTexture" IMATERIAL_PROXY_INTERFACE_VERSION );