Counter Strike : Global Offensive Source Code
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.

53 lines
1.8 KiB

  1. //========= Copyright � 1996-2005, 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. #include "imaterialproxydict.h"
  19. // memdbgon must be the last include file in a .cpp file!!!
  20. #include "tier0/memdbgon.h"
  21. class CAnimateSpecificTexture : public CBaseAnimatedTextureProxy
  22. {
  23. private:
  24. CUtlString m_OnlyAnimateOnTexture;
  25. public:
  26. virtual float GetAnimationStartTime( void* pBaseEntity ) { return 0; }
  27. virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
  28. virtual void OnBind( void *pC_BaseEntity );
  29. virtual void Release( void ) { delete this; }
  30. };
  31. bool CAnimateSpecificTexture::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
  32. {
  33. char const* pszAnimateOnTexture = pKeyValues->GetString( "onlyAnimateOnTexture" );
  34. if( !pszAnimateOnTexture )
  35. return false;
  36. m_OnlyAnimateOnTexture.Set( pszAnimateOnTexture );
  37. return CBaseAnimatedTextureProxy::Init( pMaterial, pKeyValues );
  38. }
  39. void CAnimateSpecificTexture::OnBind( void *pC_BaseEntity )
  40. {
  41. if( FStrEq( m_AnimatedTextureVar->GetTextureValue()->GetName(), m_OnlyAnimateOnTexture ) )
  42. {
  43. CBaseAnimatedTextureProxy::OnBind( pC_BaseEntity );
  44. }
  45. //else do nothing
  46. }
  47. EXPOSE_MATERIAL_PROXY( CAnimateSpecificTexture, AnimateSpecificTexture );