summaryrefslogtreecommitdiff
path: root/game/server/dod/dod_basegrenade.h
blob: 2af0d7abc4fe27bb92e09c39cd157e7b0dc48c4c (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

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

#include "weapon_dodbase.h"
#include "basegrenade_shared.h"

class CGrenadeTrail;

class CGrenadeController : public IMotionEvent
{
	DECLARE_SIMPLE_DATADESC();
public:
	virtual simresult_e	Simulate( IPhysicsMotionController *pController, IPhysicsObject *pObject, float deltaTime, Vector &linear, AngularImpulse &angular );
};

class CDODBaseGrenade : public CBaseGrenade
{
public:
	DECLARE_CLASS( CDODBaseGrenade, CBaseGrenade );

	DECLARE_DATADESC();

	DECLARE_SERVERCLASS();

	CDODBaseGrenade();
	virtual ~CDODBaseGrenade();

	virtual void Spawn();
	virtual void Precache( void );

	static inline float GetGrenadeGravity() { return 0.4f; }
	static inline const float GetGrenadeFriction() { return 0.5f; }
	static inline const float GetGrenadeElasticity() { return 0.2f; }

	void DetonateThink( void );

	virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );

	virtual char *GetExplodingClassname( void );

	virtual int	    ObjectCaps( void ) { return BaseClass::ObjectCaps() | FCAP_IMPULSE_USE | FCAP_USE_IN_RADIUS; }

	virtual	int		OnTakeDamage( const CTakeDamageInfo &info );

	virtual void	Detonate();

	bool			CreateVPhysics();
	virtual void	VPhysicsUpdate( IPhysicsObject *pPhysics );
	virtual void VPhysicsCollision( int index, gamevcollisionevent_t *pEvent );

	virtual void Explode( trace_t *pTrace, int bitsDamageType );

	void SetupInitialTransmittedGrenadeVelocity( const Vector &velocity )
	{
		m_vInitialVelocity = velocity;
	}

	CGrenadeController			m_GrenadeController;
	IPhysicsMotionController	*m_pMotionController;

	virtual bool CanBePickedUp( void ) { return true; }

	virtual void OnPickedUp( void ) {}

	virtual float GetElasticity();

	virtual DODWeaponID GetEmitterWeaponID() { return m_EmitterWeaponID; }

protected:

	//Set the time to detonate ( now + timer )
	virtual void SetDetonateTimerLength( float timer );
	float m_flDetonateTime;

	//Custom collision to allow for constant elasticity on hit surfaces
	virtual void ResolveFlyCollisionCustom( trace_t &trace, Vector &vecVelocity );

	bool	m_bUseVPhysics;

	DODWeaponID m_EmitterWeaponID;

private:		

	CDODBaseGrenade( const CDODBaseGrenade & );

	bool	m_bInSolid;

	// This gets sent to the client and placed in the client's interpolation history
	// so the projectile starts out moving right off the bat.
	CNetworkVector( m_vInitialVelocity );

	float m_flCollideWithTeammatesTime;
	bool m_bCollideWithTeammates;
};


#endif // DOD_BASEGRENADE_H