forked from hitmen047/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbaseentity_shared.h
314 lines (262 loc) · 7.42 KB
/
baseentity_shared.h
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef BASEENTITY_SHARED_H
#define BASEENTITY_SHARED_H
#ifdef _WIN32
#pragma once
#endif
extern ConVar hl2_episodic;
// Simple shared header file for common base entities
// entity capabilities
// These are caps bits to indicate what an object's capabilities (currently used for +USE, save/restore and level transitions)
#define FCAP_MUST_SPAWN 0x00000001 // Spawn after restore
#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions
// UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!!
#define FCAP_FORCE_TRANSITION 0x00000004 // ALWAYS goes across transitions
#define FCAP_NOTIFY_ON_TRANSITION 0x00000008 // Entity will receive Inside/Outside transition inputs when a transition occurs
#define FCAP_IMPULSE_USE 0x00000010 // can be used by the player
#define FCAP_CONTINUOUS_USE 0x00000020 // can be used by the player
#define FCAP_ONOFF_USE 0x00000040 // can be used by the player
#define FCAP_DIRECTIONAL_USE 0x00000080 // Player sends +/- 1 when using (currently only tracktrains)
// NOTE: Normally +USE only works in direct line of sight. Add these caps for additional searches
#define FCAP_USE_ONGROUND 0x00000100
#define FCAP_USE_IN_RADIUS 0x00000200
#define FCAP_SAVE_NON_NETWORKABLE 0x00000400
#define FCAP_MASTER 0x10000000 // Can be used to "master" other entities (like multisource)
#define FCAP_WCEDIT_POSITION 0x40000000 // Can change position and update Hammer in edit mode
#define FCAP_DONT_SAVE 0x80000000 // Don't save this
// How many bits are used to transmit parent attachment indices?
#define NUM_PARENTATTACHMENT_BITS 6
// Maximum number of vphysics objects per entity
#define VPHYSICS_MAX_OBJECT_LIST_COUNT 1024
//-----------------------------------------------------------------------------
// For invalidate physics recursive
//-----------------------------------------------------------------------------
enum InvalidatePhysicsBits_t
{
POSITION_CHANGED = 0x1,
ANGLES_CHANGED = 0x2,
VELOCITY_CHANGED = 0x4,
ANIMATION_CHANGED = 0x8,
};
#if defined( CLIENT_DLL )
#include "c_baseentity.h"
#include "c_baseanimating.h"
#else
#include "baseentity.h"
#ifdef HL2_EPISODIC
#include "info_darknessmode_lightsource.h"
#endif // HL2_EPISODIC
#endif
#if !defined( NO_ENTITY_PREDICTION )
// CBaseEntity inlines
inline bool CBaseEntity::IsPlayerSimulated( void ) const
{
return m_bIsPlayerSimulated;
}
inline CBasePlayer *CBaseEntity::GetSimulatingPlayer( void )
{
return m_hPlayerSimulationOwner;
}
#endif
inline MoveType_t CBaseEntity::GetMoveType() const
{
return (MoveType_t)(unsigned char)m_MoveType;
}
inline MoveCollide_t CBaseEntity::GetMoveCollide() const
{
return (MoveCollide_t)(unsigned char)m_MoveCollide;
}
//-----------------------------------------------------------------------------
// Collision group accessors
//-----------------------------------------------------------------------------
inline int CBaseEntity::GetCollisionGroup() const
{
return m_CollisionGroup;
}
inline int CBaseEntity::GetFlags( void ) const
{
return m_fFlags;
}
inline bool CBaseEntity::IsAlive( void )
{
return m_lifeState == LIFE_ALIVE;
}
inline CBaseEntity *CBaseEntity::GetOwnerEntity() const
{
return m_hOwnerEntity.Get();
}
inline CBaseEntity *CBaseEntity::GetEffectEntity() const
{
return m_hEffectEntity.Get();
}
inline int CBaseEntity::GetPredictionRandomSeed( bool bUseUnSyncedServerPlatTime )
{
#ifdef GAME_DLL
return bUseUnSyncedServerPlatTime ? m_nPredictionRandomSeedServer : m_nPredictionRandomSeed;
#else
return m_nPredictionRandomSeed;
#endif
}
inline CBasePlayer *CBaseEntity::GetPredictionPlayer( void )
{
return m_pPredictionPlayer;
}
inline void CBaseEntity::SetPredictionPlayer( CBasePlayer *player )
{
m_pPredictionPlayer = player;
}
inline bool CBaseEntity::IsSimulatedEveryTick() const
{
return m_bSimulatedEveryTick;
}
inline bool CBaseEntity::IsAnimatedEveryTick() const
{
return m_bAnimatedEveryTick;
}
inline void CBaseEntity::SetSimulatedEveryTick( bool sim )
{
if ( m_bSimulatedEveryTick != sim )
{
m_bSimulatedEveryTick = sim;
#ifdef CLIENT_DLL
Interp_UpdateInterpolationAmounts( GetVarMapping() );
#endif
}
}
inline void CBaseEntity::SetAnimatedEveryTick( bool anim )
{
if ( m_bAnimatedEveryTick != anim )
{
m_bAnimatedEveryTick = anim;
#ifdef CLIENT_DLL
Interp_UpdateInterpolationAmounts( GetVarMapping() );
#endif
}
}
inline float CBaseEntity::GetAnimTime() const
{
return m_flAnimTime;
}
inline float CBaseEntity::GetSimulationTime() const
{
return m_flSimulationTime;
}
inline void CBaseEntity::SetAnimTime( float at )
{
m_flAnimTime = at;
}
inline void CBaseEntity::SetSimulationTime( float st )
{
m_flSimulationTime = st;
}
inline int CBaseEntity::GetEffects( void ) const
{
return m_fEffects;
}
inline void CBaseEntity::RemoveEffects( int nEffects )
{
#if !defined( CLIENT_DLL )
#ifdef HL2_EPISODIC
if ( nEffects & (EF_BRIGHTLIGHT|EF_DIMLIGHT) )
{
// Hack for now, to avoid player emitting radius with his flashlight
if ( !IsPlayer() )
{
RemoveEntityFromDarknessCheck( this );
}
}
#endif // HL2_EPISODIC
#endif // !CLIENT_DLL
m_fEffects &= ~nEffects;
if ( nEffects & EF_NODRAW )
{
#ifndef CLIENT_DLL
NetworkProp()->MarkPVSInformationDirty();
DispatchUpdateTransmitState();
#else
UpdateVisibility();
#endif
}
}
inline void CBaseEntity::ClearEffects( void )
{
#if !defined( CLIENT_DLL )
#ifdef HL2_EPISODIC
if ( m_fEffects & (EF_BRIGHTLIGHT|EF_DIMLIGHT) )
{
// Hack for now, to avoid player emitting radius with his flashlight
if ( !IsPlayer() )
{
RemoveEntityFromDarknessCheck( this );
}
}
#endif // HL2_EPISODIC
#endif // !CLIENT_DLL
m_fEffects = 0;
#ifndef CLIENT_DLL
DispatchUpdateTransmitState();
#else
UpdateVisibility();
#endif
}
inline bool CBaseEntity::IsEffectActive( int nEffects ) const
{
return (m_fEffects & nEffects) != 0;
}
// Shared EntityMessage between game and client .dlls
#define BASEENTITY_MSG_REMOVE_DECALS 1
extern float k_flMaxEntityPosCoord;
extern float k_flMaxEntityEulerAngle;
extern float k_flMaxEntitySpeed;
extern float k_flMaxEntitySpinRate;
inline bool IsEntityCoordinateReasonable ( const vec_t c )
{
float r = k_flMaxEntityPosCoord;
return c > -r && c < r;
}
inline bool IsEntityPositionReasonable( const Vector &v )
{
float r = k_flMaxEntityPosCoord;
return
v.x > -r && v.x < r &&
v.y > -r && v.y < r &&
v.z > -r && v.z < r;
}
// Returns:
// -1 - velocity is really, REALLY bad and probably should be rejected.
// 0 - velocity was suspicious and clamped.
// 1 - velocity was OK and not modified
extern int CheckEntityVelocity( Vector &v );
inline bool IsEntityQAngleReasonable( const QAngle &q )
{
float r = k_flMaxEntityEulerAngle;
return
q.x > -r && q.x < r &&
q.y > -r && q.y < r &&
q.z > -r && q.z < r;
}
// Angular velocity in exponential map form
inline bool IsEntityAngularVelocityReasonable( const Vector &q )
{
float r = k_flMaxEntitySpinRate;
return
q.x > -r && q.x < r &&
q.y > -r && q.y < r &&
q.z > -r && q.z < r;
}
// Angular velocity of each Euler angle.
inline bool IsEntityQAngleVelReasonable( const QAngle &q )
{
float r = k_flMaxEntitySpinRate;
return
q.x > -r && q.x < r &&
q.y > -r && q.y < r &&
q.z > -r && q.z < r;
}
extern bool CheckEmitReasonablePhysicsSpew();
#endif // BASEENTITY_SHARED_H