aboutsummaryrefslogtreecommitdiff
path: root/sp/src/game/client/AnimateSpecificTextureProxy.cpp
blob: e4fe742ffeb43574a49a23f1c2d049b139155057 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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 );