summaryrefslogtreecommitdiff
path: root/game/shared/tf/tf_logic_player_destruction.h
blob: b7700924121a77a74a2878cd23bc845d81ff432b (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Entities for use in the Robot Destruction TF2 game mode.
//
//=========================================================================//
#ifndef PLAYER_DESTRUCTION_H
#define PLAYER_DESTRUCTION_H
#pragma once

#include "cbase.h"
#include "tf_logic_robot_destruction.h"

#ifdef CLIENT_DLL
	#define CTFPlayerDestructionLogic C_TFPlayerDestructionLogic
	#define CPlayerDestructionDispenser C_PlayerDestructionDispenser
#endif

//-----------------------------------------------------------------------------
class CTFPlayerDestructionLogic : public CTFRobotDestructionLogic
{
public:
#ifdef GAME_DLL
	DECLARE_DATADESC();
#endif // GAME_DLL
	DECLARE_CLASS( CTFPlayerDestructionLogic, CTFRobotDestructionLogic )
	DECLARE_NETWORKCLASS();

	virtual EType GetType() const { return TYPE_PLAYER_DESTRUCTION; }

	CTFPlayerDestructionLogic();
	static CTFPlayerDestructionLogic* GetPlayerDestructionLogic();

	CTFPlayer* GetRedTeamLeader() const { return m_hRedTeamLeader.Get(); }
	CTFPlayer* GetBlueTeamLeader() const { return m_hBlueTeamLeader.Get(); }

#ifdef GAME_DLL
	virtual void Precache() OVERRIDE;

	const char *GetPropModelName() const;

	void CalcTeamLeader( int iTeam );

	virtual void FireGameEvent( IGameEvent *pEvent ) OVERRIDE;

	void InputScoreRedPoints( inputdata_t& inputdata );
	void InputScoreBluePoints( inputdata_t& inputdata );
	void InputEnableMaxScoreUpdating( inputdata_t& inputdata );
	void InputDisableMaxScoreUpdating( inputdata_t& inputdata );
	void InputSetCountdownTimer( inputdata_t& inputdata );
	void InputSetCountdownImage( inputdata_t& inputdata );
	void InputSetFlagResetDelay( inputdata_t& inputdata );
	void InputSetPointsOnPlayerDeath( inputdata_t& inputdata );

	void PlayPropDropSound( CTFPlayer *pPlayer );
	void PlayPropPickupSound( CTFPlayer *pPlayer );

	void CountdownThink( void );
	int GetFlagResetDelay( void ){ return m_nFlagResetDelay; }
	int GetPointsOnPlayerDeath( void ){ return m_nPointsOnPlayerDeath; }
	virtual int GetHealDistance( void ) OVERRIDE { return m_nHealDistance; }
	virtual void TeamWin( int nTeam ) OVERRIDE;

#endif // GAME_DLL

	CTFPlayer *GetTeamLeader( int iTeam ) const OVERRIDE;
	string_t GetCountdownImage( void ) OVERRIDE { return m_iszCountdownImage; }
	virtual bool IsUsingCustomCountdownImage( void ) OVERRIDE{ return m_bUsingCountdownImage; }

private:
#ifdef GAME_DLL
	void PlaySound( const char *pszSound, CTFPlayer *pPlayer );
	virtual void OnRedScoreChanged() OVERRIDE;
	virtual void OnBlueScoreChanged() OVERRIDE;
	
	void EvaluatePlayerCount();

	void SetCountdownImage( string_t iszCountdownImage ) { m_iszCountdownImage = iszCountdownImage; }

	string_t m_iszPropModelName;
	string_t m_iszPropDropSound;
	string_t m_iszPropPickupSound;

	int m_nMinPoints;
	int m_nPointsPerPlayer;
	bool m_bMaxScoreUpdatingAllowed;

	int m_nFlagResetDelay;
	int m_nHealDistance;

	CObjectDispenser* CreateDispenser( int iTeam );
	CHandle< CObjectDispenser > m_hRedDispenser;
	CHandle< CObjectDispenser > m_hBlueDispenser;

	COutputFloat m_OnRedScoreChanged;
	COutputFloat m_OnBlueScoreChanged;

	COutputEvent m_OnCountdownTimerExpired;
#endif // GAME_DLL

	CNetworkVar( CHandle<CTFPlayer>, m_hRedTeamLeader );
	CNetworkVar( CHandle<CTFPlayer>, m_hBlueTeamLeader );

	CNetworkVar( bool, m_bUsingCountdownImage );

#ifdef CLIENT_DLL
	char		m_iszCountdownImage[MAX_PATH];
#else
	CNetworkVar( string_t, m_iszCountdownImage );
	int m_nPointsOnPlayerDeath;
#endif
};

class CPlayerDestructionDispenser :
#ifdef GAME_DLL
	public CObjectDispenser
#else
	public C_ObjectDispenser
#endif
{
#ifdef GAME_DLL
	DECLARE_CLASS( CPlayerDestructionDispenser, CObjectDispenser )
#else
	DECLARE_CLASS( CPlayerDestructionDispenser, C_ObjectDispenser )
#endif
	DECLARE_NETWORKCLASS();
	DECLARE_DATADESC();
public:
#ifdef GAME_DLL
	virtual float GetDispenserRadius( void ) OVERRIDE
	{
		if ( CTFPlayerDestructionLogic::GetRobotDestructionLogic() && ( CTFPlayerDestructionLogic::GetRobotDestructionLogic()->GetType() == CTFPlayerDestructionLogic::TYPE_PLAYER_DESTRUCTION ) )
		{
			return CTFPlayerDestructionLogic::GetRobotDestructionLogic()->GetHealDistance();
		}

		return 450;
	}

	virtual void Spawn( void ) OVERRIDE;
	void OnGoActive( void ) OVERRIDE;
	void GetControlPanelInfo( int nPanelIndex, const char *&pPanelName ) OVERRIDE;

#endif
};

#endif// PLAYER_DESTRUCTION_H