summaryrefslogtreecommitdiff
path: root/game/shared/tf/tf_weapon_grapplinghook.h
blob: 6864249abffeedf55c75c17bf7975130456bf3c1 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// TF Grappling Hook
//
//=============================================================================
#ifndef TF_WEAPON_GRAPPLINGHOOK_H
#define TF_WEAPON_GRAPPLINGHOOK_H
#ifdef _WIN32
#pragma once
#endif

#include "tf_weapon_rocketlauncher.h"

#ifdef CLIENT_DLL
#include "econ_notifications.h"

#define CTFGrapplingHook C_TFGrapplingHook
#endif // CLIENT_DLL

// ------------------------------------------------------------------------------------------------------------------------
class CTFGrapplingHook : public CTFRocketLauncher
{
public:
	DECLARE_CLASS( CTFGrapplingHook, CTFRocketLauncher );
	DECLARE_NETWORKCLASS(); 
	DECLARE_PREDICTABLE();

	// Server specific.
#ifdef GAME_DLL
	DECLARE_DATADESC();
#endif // GAME_DLL

	CTFGrapplingHook();

	virtual void	Precache() OVERRIDE;
	virtual CBaseEntity *FireProjectile( CTFPlayer *pPlayer ) OVERRIDE;
	virtual void	ItemPostFrame( void ) OVERRIDE;
	virtual bool	CanAttack( void ) OVERRIDE;
	virtual void	PrimaryAttack( void ) OVERRIDE;
	virtual bool	Deploy( void ) OVERRIDE;
	virtual bool	Holster( CBaseCombatWeapon *pSwitchingTo ) OVERRIDE;
	virtual void	GetProjectileFireSetup( CTFPlayer *pPlayer, Vector vecOffset, Vector *vecSrc, QAngle *angForward, bool bHitTeammates = true, float flEndDist = 2000.f ) OVERRIDE;

	virtual int		GetWeaponID( void ) const OVERRIDE { return TF_WEAPON_GRAPPLINGHOOK; }
	virtual float	GetProjectileSpeed( void ) OVERRIDE;
	virtual float	GetProjectileGravity( void ) OVERRIDE { return 0.f; }
	virtual int		GetWeaponProjectileType( void ) const OVERRIDE { return TF_PROJECTILE_GRAPPLINGHOOK; }
	virtual bool	ShouldRemoveDisguiseOnPrimaryAttack() const OVERRIDE { return false; }
	virtual bool	ShouldRemoveInvisibilityOnPrimaryAttack() const OVERRIDE { return false; }
	virtual int		GetCanAttackFlags() const OVERRIDE { return TF_CAN_ATTACK_FLAG_GRAPPLINGHOOK; }

	virtual bool	SendWeaponAnim( int iActivity );

	virtual void	PlayWeaponShootSound( void ) OVERRIDE;

#ifdef CLIENT_DLL
	virtual void	UpdateOnRemove() OVERRIDE;
	virtual void	OnDataChanged( DataUpdateType_t type ) OVERRIDE;
#endif // CLIENT_DLL


	// acttable override
	virtual acttable_t *ActivityList( int &iActivityCount ) OVERRIDE;

	// poseparam override
	virtual poseparamtable_t *PoseParamList( int &iPoseParamCount ) OVERRIDE;

#ifdef GAME_DLL
	void			ActivateRune();
#endif // GAME_DLL

private:
#ifdef GAME_DLL
	void			RemoveHookProjectile( bool bForce = false );
	bool			IsLatchedToTargetPlayer() const;
	bool			m_bReleasedAfterLatched;
#endif // GAME_DLL

#ifdef CLIENT_DLL
	void			StartHookSound();
	void			StopHookSound();
	void			UpdateHookSound();
	CSoundPatch		*m_pHookSound;
	bool			m_bLatched;
	float			m_flNextSupernovaDenyWarning;
#endif // CLIENT_DLL

	void			OnHookReleased( bool bForce );

	CNetworkHandle( CBaseEntity, m_hProjectile );
	CountdownTimer m_startFiringTimer;
	CountdownTimer m_startPullingTimer;
};

#ifdef CLIENT_DLL

class CEquipGrapplingHookNotification : public CEconNotification
{
public:
	CEquipGrapplingHookNotification() : CEconNotification()
	{
		m_bHasTriggered = false;
	}

	~CEquipGrapplingHookNotification()
	{
		if ( !m_bHasTriggered )
		{
			m_bHasTriggered = true;
		}
	}

	virtual void MarkForDeletion()
	{
		m_bHasTriggered = true;
		CEconNotification::MarkForDeletion();
	}

	virtual bool BShowInGameElements() const { return true; }
	virtual EType NotificationType() { return eType_AcceptDecline; }

	virtual void Accept();
	virtual void Trigger() { Accept(); }
	virtual void Decline() { MarkForDeletion(); }
	virtual void UpdateTick();

	static bool IsNotificationType( CEconNotification *pNotification ) { return dynamic_cast< CEquipGrapplingHookNotification *>( pNotification ) != NULL; }

private:
	bool m_bHasTriggered;
};

#endif // CLIENT_DLL

#endif // TF_WEAPON_GRAPPLINGHOOK_H