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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Client's sheild entity
//
// $Workfile: $
// $Date: $
// $NoKeywords: $
//=============================================================================//
#ifndef C_SHIELD_H
#define C_SHIELD_H
#ifdef _WIN32
#pragma once
#endif
#include "SplinePatch.h"
//-----------------------------------------------------------------------------
// Shield:
//-----------------------------------------------------------------------------
class C_Shield : public C_BaseEntity
{
public:
DECLARE_CLASS( C_Shield, C_BaseEntity );
DECLARE_CLIENTCLASS();
// constructor, destructor
C_Shield();
~C_Shield();
// Inherited classes should call this in their constructor to indicate size...
void InitShield( int w, int h, int subdivisions );
void OnDataChanged( DataUpdateType_t updateType );
int DrawModel( int flags );
void ReceiveMessage( int classID, bf_read &msg );
void CreateShieldDeflection( int hitgroup, const Vector &dir, bool partialBlock );
virtual bool ShouldDraw();
virtual bool IsTransparent() { return true; }
virtual void SetAlwaysOrient( bool bOrient ) {}
virtual bool IsAlwaysOrienting( ) { return false; }
virtual void SetCenterAngles( const QAngle & ) {}
virtual void SetAttachmentIndex( int nAttachmentIndex ) {}
// returns the address of a variable that stores the material animation frame
float GetTextureAnimationStartTime();
// Indicates that a texture animation has wrapped
void TextureAnimationWrapped();
virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const;
// Collision detection
// Activates/deactivates a shield for collision purposes
void ActivateCollisions( bool activate );
// Deactivates all shields of players on a particular team
// If you don't specify a team, it'll affect all shields
static void ActivateShields( bool activate, int team = -1 );
virtual const Vector& GetPoint( int x, int y ) { return vec3_origin; }
// For collision testing
bool TestCollision( const Ray_t& ray, unsigned int mask, trace_t& trace );
// Called when we hit something that we deflect...
void RegisterDeflection(const Vector& vecDir, int bitsDamageType, trace_t *ptr);
float GetPowerLevel( void ) { return m_flPowerLevel; }
bool IsEMPed() const;
void SetEMPed( bool bIsEmped );
protected:
//
// Inheriting classes must implement these methods!!!
//
// Return true if the panel is active
virtual bool IsPanelActive( int x, int y ) { assert(0); return false; }
// Gets at the control point data; who knows how it was made?
virtual void GetShieldData( Vector const** ppVerts, float* pOpacity, float* pBlend ) { assert(0); }
private:
void DrawWireframeModel( Vector const** pPositions );
void ComputePoint( float s, float t, Vector& pt, Vector& normal, float& opacity );
void ComputeShieldPoints( Vector* pt, Vector* normal, float* opacity );
void RippleShieldPoints( Vector* pt, float* opacity );
void DrawShieldPoints(Vector* pt, Vector* normal, float* opacity);
void DrawShieldDecals(Vector* pt, bool hitDecals );
void SetCurrentDecal( int idx );
int Width() const;
int Height() const;
protected:
// Used to fade out the shield
float m_FadeValue;
// Used to make the shield more or less curvy
float m_CurveValue;
private:
// no copy constructor
C_Shield( const C_Shield& );
// Data needs to ripple the shield control points
struct Ripple_t
{
float m_RippleU;
float m_RippleV;
float m_Amplitude;
float m_Radius;
float m_StartTime;
Vector m_Direction;
};
struct Decal_t
{
float m_RippleU;
float m_RippleV;
float m_Radius;
float m_StartTime;
};
// Owner entity
int m_nOwningPlayerIndex;
// number of subdivisions
int m_SubdivisionCount;
float m_InvSubdivisionCount;
// Shield powerlevel
float m_flPowerLevel;
// Texture animation
float m_StartTime;
bool m_bCollisionsActive;
bool m_bIsEMPed;
// Used to do spline queries
CSplinePatch m_SplinePatch;
// List of all ripples + decals
int m_CurrentDecal;
CUtlVector< Ripple_t > m_Ripples;
CUtlVector< Decal_t > m_Decals;
// All the various materials we use
CMaterialReference m_pWireframe;
CMaterialReference m_pShield;
CMaterialReference m_pHitDecal;
CMaterialReference m_pPassDecal;
CMaterialReference m_pPassDecal2;
// A little state used only during rendering, but I didn't want
// to pass these as arguments to a bunch of functions
bool m_ShieldOwnedByLocalPlayer;
Vector m_ViewDir;
// List of all active shields
static CUtlVector< C_Shield* > s_Shields;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline int C_Shield::Width() const
{
return m_SplinePatch.Width();
}
inline int C_Shield::Height() const
{
return m_SplinePatch.Height();
}
inline bool C_Shield::IsEMPed() const
{
return m_bIsEMPed;
}
inline void C_Shield::SetEMPed( bool bIsEmped )
{
m_bIsEMPed = bIsEmped;
}
//-----------------------------------------------------------------------------
// Class factory methods to create the various versions of the shield
//-----------------------------------------------------------------------------
C_Shield* CreateMobileShield( C_BaseEntity *owner, float flFrontDistance = 0 );
#endif // C_SHIELD_H
|