aboutsummaryrefslogtreecommitdiff
path: root/sp/src/game/client/tempent.h
blob: 16b5653cbade3e2961ec55a0e74a3f38c41eb055 (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
147
148
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//=============================================================================//
#if !defined( TEMPENT_H )
#define TEMPENT_H
#ifdef _WIN32
#pragma once
#endif

#include "c_baseentity.h"
#include "c_baseanimating.h"
#include "c_sprite.h"

// Temporary entity array
#define TENTPRIORITY_LOW	0
#define TENTPRIORITY_HIGH	1

// TEMPENTITY flags
#define	FTENT_NONE					0x00000000
#define	FTENT_SINEWAVE				0x00000001
#define	FTENT_GRAVITY				0x00000002
#define FTENT_ROTATE				0x00000004
#define	FTENT_SLOWGRAVITY			0x00000008
#define FTENT_SMOKETRAIL			0x00000010
#define FTENT_COLLIDEWORLD			0x00000020
#define FTENT_FLICKER				0x00000040
#define FTENT_FADEOUT				0x00000080
#define FTENT_SPRANIMATE			0x00000100
#define FTENT_HITSOUND				0x00000200
#define FTENT_SPIRAL				0x00000400
#define FTENT_SPRCYCLE				0x00000800
#define FTENT_COLLIDEALL			0x00001000 // will collide with world and slideboxes
#define FTENT_PERSIST				0x00002000 // tent is not removed when unable to draw 
#define FTENT_COLLIDEKILL			0x00004000 // tent is removed upon collision with anything
#define FTENT_PLYRATTACHMENT		0x00008000 // tent is attached to a player (owner)
#define FTENT_SPRANIMATELOOP		0x00010000 // animating sprite doesn't die when last frame is displayed
#define FTENT_SMOKEGROWANDFADE		0x00020000 // rapid grow and fade. Very specific for gunsmoke
#define FTENT_ATTACHTOTARGET		0x00040000 // attach to whatever we hit, and stay there until die time is up
#define FTENT_NOMODEL				0x00080000 // Doesn't have a model, never try to draw ( it just triggers other things )
#define FTENT_CLIENTCUSTOM			0x00100000 // Must specify callback.  Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things )
#define FTENT_WINDBLOWN				0x00200000 // This is set when the temp entity is blown by the wind
#define FTENT_NEVERDIE				0x00400000 // Don't die as long as die != 0
#define FTENT_BEOCCLUDED			0x00800000 // Don't draw if my specified normal's facing away from the view
#define FTENT_CHANGERENDERONCOLLIDE	0x01000000	//when we collide with something, change our rendergroup to RENDER_GROUP_OTHER
#define FTENT_COLLISIONGROUP		0x02000000	// if set, use the C_BaseEntity::GetCollisionGroup when doing collide trace
#define FTENT_ALIGNTOMOTION			0x04000000	// Change angles to always point in the direction of motion
#define FTENT_CLIENTSIDEPARTICLES	0x08000000	// The object has a clientside particle system.
#define FTENT_USEFASTCOLLISIONS		0x10000000	// Use fast collisions (cl_fasttempentcollision).
#define FTENT_COLLIDEPROPS			0x20000000	// Collide with the world and props

class C_LocalTempEntity;

typedef int (*pfnDrawHelper)( C_LocalTempEntity *entity, int flags );

//-----------------------------------------------------------------------------
// Purpose: Should this derive from some other class
//-----------------------------------------------------------------------------
class C_LocalTempEntity : public C_BaseAnimating, public C_SpriteRenderer
{
public:
	DECLARE_CLASS( C_LocalTempEntity, C_BaseAnimating );

	C_LocalTempEntity();

	virtual void					Prepare( const model_t *pmodel, float time );

	virtual bool					IsActive( void );
	virtual bool					Frame( float frametime, int framenumber );

	// C_BaseAnimating , etc. override
	virtual int						DrawModel( int flags );

	// Sets the velocity
	void SetVelocity( const Vector &vecVelocity );
	const Vector &GetVelocity() const { return m_vecTempEntVelocity; }

	// Set the acceleration
	void SetAcceleration( const Vector &vecAccel );
	const Vector &GetAcceleration() const { return m_vecTempEntAcceleration; }

	void							SetDrawHelper( pfnDrawHelper helper ) { m_pfnDrawHelper = helper; }
	void							OnRemoveTempEntity();

	void							SetImpactEffect( const char *pszImpactEffect ) { m_pszImpactEffect = pszImpactEffect; }
	CNewParticleEffect*				AddParticleEffect( const char *pszParticleEffect );
	void							SetParticleEffect( const char *pszParticleEffect ) { m_pszParticleEffect = pszParticleEffect; }

protected:

	pfnDrawHelper					m_pfnDrawHelper;

public:
	int								flags;
	float							die;
	float							m_flFrameMax;
	float							x;
	float							y;
	float							fadeSpeed;
	float							bounceFactor;
	int								hitSound;
	int								priority;
	// if attached, this is the index of the client to stick to
	// if COLLIDEALL, this is the index of the client to ignore
	// TENTS with FTENT_PLYRATTACHMENT MUST set the clientindex! 
	short							clientIndex;	

	// if attached, client origin + tentOffset = tent origin.
	Vector							tentOffset;		

	// Used by temp entities.
	QAngle							m_vecTempEntAngVelocity;
	int								tempent_renderamt;
	Vector							m_vecNormal;

	float							m_flSpriteScale;
	int								m_nFlickerFrame;

	// 
	float							m_flFrameRate;
	float							m_flFrame;

	RenderGroup_t					m_RenderGroup;

	const char						*m_pszImpactEffect;
	const char						*m_pszParticleEffect;
	bool							m_bParticleCollision;

	int								m_iLastCollisionFrame;
	Vector							m_vLastCollisionOrigin;

private:
	C_LocalTempEntity( const C_LocalTempEntity & );

	Vector							m_vecTempEntVelocity;
	Vector							m_vecPrevLocalOrigin;

	Vector							m_vecTempEntAcceleration;

	// Draw tempent as a studio model
	int								DrawStudioModel( int flags );

};

#endif // TEMPENTITY_H