summaryrefslogtreecommitdiff
path: root/game/server/tf2/tf_basefourwheelvehicle.h
blob: f9c62050f3e8a0bd79fedfbd61b0ac48262f28cf (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: A base class that deals with four-wheel vehicles
//
// $NoKeywords: $
//=============================================================================//

#ifndef TF_BASE_FOUR_WHEEL_VEHICLE_H
#define TF_BASE_FOUR_WHEEL_VEHICLE_H

#ifdef _WIN32
#pragma once
#endif

#include "basetfvehicle.h"
#include "vphysics/vehicles.h"
#include "fourwheelvehiclephysics.h"
#include "tf_vehicleshared.h"

class CMoveData;

class CBaseTFFourWheelVehicle : public CBaseTFVehicle
{
public:
	DECLARE_CLASS( CBaseTFFourWheelVehicle, CBaseTFVehicle );
	DECLARE_SERVERCLASS();

public:
	CBaseTFFourWheelVehicle();
	~CBaseTFFourWheelVehicle ();
			 
	// CBaseEntity
	void Spawn();
	void Precache();
	void VPhysicsUpdate( IPhysicsObject *pPhysics );
	void DrawDebugGeometryOverlays();
	int DrawDebugTextOverlays();
	void Teleport( const Vector *newPosition, const QAngle *newAngles, const Vector *newVelocity );
	void BaseFourWheeledVehicleThink();
	void BaseFourWheeledVehicleDeployThink( void );

	// HACK HACK:  This is a hack to avoid physics spazzing out on a newly created vehicle with the handbrake
	//  set.  We create and activate it, but then release the handbrake for a single Think function call and 
	//  then zero out the controls right then.  This seems to stabilize something in the physics simulator.
	void BaseFourWheeledVehicleStopTheRodeoMadnessThink( void );

	virtual bool StartBuilding( CBaseEntity *pPlayer );
	virtual void FinishedBuilding( void );

	virtual void SetupMove( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move );
	virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMoveData );
	virtual void SetPassenger( int nRole, CBasePlayer *pEnt );

	// Powerup handling
	virtual void PowerupStart( int iPowerup, float flAmount, CBaseEntity *pAttacker, CDamageModifier *pDamageModifier );
	virtual	void PowerupEnd( int iPowerup );

	// Collision
	virtual void	VPhysicsCollision( int index, gamevcollisionevent_t *pEvent );

	// Inputs
	void InputThrottle( inputdata_t &inputdata );
	void InputSteering( inputdata_t &inputdata );
	void InputAction( inputdata_t &inputdata );
	void InputTurnOn( inputdata_t &inputdata );
	void InputTurnOff( inputdata_t &inputdata );

	// Boost
	void			SetBoostUpgrade( bool bBoostUpgrade ); 
	bool			IsBoostable( void );
	bool			IsBoosting( void );
	void			StartBoost( void );

	bool			IsDeployed( void ) { return ( m_eDeployMode == VEHICLE_MODE_DEPLOYED ); }
	bool			IsDeploying( void ) { return ( m_eDeployMode == VEHICLE_MODE_DEPLOYING ); }
	bool			IsUndeploying( void ) { return ( m_eDeployMode == VEHICLE_MODE_UNDEPLOYING ); }
	bool			InDeployMode( void ) { return ( m_eDeployMode != VEHICLE_MODE_NORMAL ); }

	DECLARE_DATADESC();

	// locals
protected:
	// engine sounds
	void SoundInit();
	void SoundShutdown();
	void SoundUpdate( const vehicle_operatingparams_t &params, const vehicleparams_t &vehicle );
	void CalcWheelData( vehicleparams_t &vehicle );
	void ResetControls();

	// Deploy
	bool			Deploy( void );
	void			UnDeploy( void );
	void			CancelDeploy( void );
	virtual void	OnFinishedDeploy( void );
	virtual void	OnFinishedUnDeploy( void );

private:
	void DriveVehicle( CBasePlayer *pPlayer, CUserCmd *ucmd );
	void PlayerControlInit( CBasePlayer *pPlayer );
	void PlayerControlShutdown();
	void ResetUseKey( CBasePlayer *pPlayer );
	void InitializePoseParameters();
	bool ParseVehicleScript( solid_t &solid, vehicleparams_t &vehicle );

	void EnableMotion( void );
	void DisableMotion( void );

private:
	CFourWheelVehiclePhysics	m_VehiclePhysics;
	COutputEvent				m_playerOn;
	COutputEvent				m_playerOff;

	COutputEvent				m_pressedAttack;
	COutputEvent				m_pressedAttack2;

	COutputFloat				m_attackaxis;
	COutputFloat				m_attack2axis;

	int							m_nMovementRole;
	Vector						m_savedViewOffset; //[MAX_PASSENGERS];
	
	float						m_flNextEmpSound;

	// Deploy
	CNetworkVar( VehicleModeDeploy_e, m_eDeployMode );
	Activity					m_PreDeployActivity;

	// Used for vgui screens on the client.
	CNetworkVar( float, m_flDeployFinishTime );
	CNetworkVar( bool, m_bBoostUpgrade );
	CNetworkVar( int, m_nBoostTimeLeft );

	float						m_flNextHitTime;
};



#endif // TF_BASE_FOUR_WHEEL_VEHICLE_H