summaryrefslogtreecommitdiff
path: root/game/server/tf/tf_obj_spy_trap.h
blob: b39570de655a3d6fdf66fcbe8c1741122b1756f5 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//
//
//=============================================================================

#ifndef TF_OBJ_SPY_TRAP_H
#define TF_OBJ_SPY_TRAP_H
#ifdef _WIN32
#pragma once
#endif

#include "tf_obj.h"

#ifdef STAGING_ONLY
#define SPY_TRAP_MAX_HEALTH	150

// ------------------------------------------------------------------------ //
// Base trap
// ------------------------------------------------------------------------ //
class CObjectSpyTrap : public CBaseObject
{
	DECLARE_CLASS( CObjectSpyTrap, CBaseObject );
	DECLARE_DATADESC();
public:
	//DECLARE_SERVERCLASS();

	CObjectSpyTrap();

	virtual void Spawn() OVERRIDE;
	virtual void Precache() OVERRIDE;
	virtual void SetObjectMode( int iVal ) OVERRIDE;
	virtual bool IsPlacementPosValid( void ) OVERRIDE;
	virtual void StartTouch( CBaseEntity *pOther ) OVERRIDE;
	virtual void EndTouch( CBaseEntity *pOther ) OVERRIDE;
	virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const OVERRIDE;
	virtual void OnGoActive() OVERRIDE;
	virtual int	GetBaseHealth( void ) OVERRIDE { return SPY_TRAP_MAX_HEALTH; }

	void SetTrapType( int nType ) { m_nTrapMode = nType; }
	int	GetTrapType( void ) { return m_nTrapMode; }
	void SpyTrapThink();

	enum AttributeType
	{
		TRAP_TRIGGER_FRIENDLY			= 1<<0,					// Trap triggered by friendlies (a buff)
		TRAP_TRIGGER_ONBUILD			= 1<<1,					// Trap effect happens on placement
		TRAP_PULSE_EFFECT				= 1<<2,					// Trap's effect pulses on a timer
	};
	void SetAttribute( int attributeFlag );
	bool HasAttribute( int attributeFlag ) const;

private:
	void Activate( CBaseEntity *pTouchEntity );
	void Destroy( void );
	void TriggerTrapEffects( void );

	// Sapper
	void TriggerTrap_RadiusCloak( void );
	bool IsValidRadiusCloakTarget( CTFPlayer *pTarget );

	// Reprogrammer
	void TriggerTrap_Reprogrammer( CBaseEntity *pTouchEntity );

	// Magnet
	void TriggerTrap_Magnet( void );

	int m_attributeFlags;
	bool m_bActive;
	int m_nTrapMode;
	float m_flNextTrapEffectTime;
	float m_flTrapExpireTime;
	float m_flNextPulseTime;
};

inline void CObjectSpyTrap::SetAttribute( int attributeFlag )
{
	m_attributeFlags |= attributeFlag;
}

inline bool CObjectSpyTrap::HasAttribute( int attributeFlag ) const
{
	return m_attributeFlags & attributeFlag ? true : false;
}

#endif // STAGING_ONLY

#endif // TF_OBJ_SPY_TRAP_H