aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/server/env_texturetoggle.cpp
blob: 53ccbd5fe35b2a060dfa4fdd1688c7d9285fe345 (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
54
55
56
57
58
59
60
61
62
63
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#include "cbase.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

class CTextureToggle : public CPointEntity
{
public:
	DECLARE_CLASS( CTextureToggle, CPointEntity );

	void	InputIncrementBrushTexIndex( inputdata_t &inputdata );
	void	InputSetBrushTexIndex( inputdata_t &inputdata );

private:
	
	DECLARE_DATADESC();
};

LINK_ENTITY_TO_CLASS( env_texturetoggle, CTextureToggle );

BEGIN_DATADESC( CTextureToggle )

	DEFINE_INPUTFUNC( FIELD_VOID, "IncrementTextureIndex", InputIncrementBrushTexIndex ),
	DEFINE_INPUTFUNC( FIELD_INTEGER, "SetTextureIndex", InputSetBrushTexIndex ),

END_DATADESC()

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &inputdata - 
//-----------------------------------------------------------------------------
void CTextureToggle::InputIncrementBrushTexIndex( inputdata_t& inputdata )
{
	CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, m_target );
		
	while( pEntity ) 
	{
		int iCurrentIndex =  pEntity->GetTextureFrameIndex() + 1;
		pEntity->SetTextureFrameIndex( iCurrentIndex );

		pEntity = gEntList.FindEntityByName( pEntity, m_target ); 
	}
}

void CTextureToggle::InputSetBrushTexIndex( inputdata_t& inputdata )
{
	CBaseEntity *pEntity = gEntList.FindEntityByName( NULL, m_target );
		
	while( pEntity ) 
	{
		int iData = inputdata.value.Int();

		pEntity->SetTextureFrameIndex( iData );
		pEntity = gEntList.FindEntityByName( pEntity, m_target ); 
	}
}