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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef PHYSPROPCLIENTSIDE_H
#define PHYSPROPCLIENTSIDE_H
#ifdef _WIN32
#pragma once
#endif
#include "c_breakableprop.h"
#include "props_shared.h"
class C_FuncPhysicsRespawnZone;
class C_PhysPropClientside : public C_BreakableProp, public IBreakableWithPropData, public IMultiplayerPhysics
{
public:
DECLARE_CLASS( C_PhysPropClientside, C_BreakableProp );
C_PhysPropClientside();
virtual ~C_PhysPropClientside();
bool Initialize();
void Spawn();
int ParsePropData( void );
virtual bool IsDormant( void ) { return false; } // we could add a PVS check here
virtual void ClientThink( void );
virtual CollideType_t GetCollideType( void ) { return ENTITY_SHOULD_RESPOND; }
virtual void StartTouch( C_BaseEntity *pOther );
virtual void HitSurface( C_BaseEntity *pOther );
virtual void ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName );
virtual bool IsClientCreated( void ) const { return true; }
virtual int GetMultiplayerPhysicsMode() { return m_iPhysicsMode; }
virtual float GetMass();
virtual bool IsAsleep();
virtual bool KeyValue( const char *szKeyName, const char *szValue );
virtual void OnTakeDamage( int iDamage ); // very simple version
virtual void Break();
virtual void Clone( Vector &velocity );
virtual void StartFadeOut( float fTime );
virtual void SetHealth(int iHealth) { m_iHealth = iHealth; }
virtual int GetHealth() const { return m_iHealth; }
int GetNumBreakableChunks( void ) { return m_iNumBreakableChunks; }
void SetRespawnZone( C_FuncPhysicsRespawnZone *pZone );
// IBreakableWithPropData interface:
public:
// IBreakableWithPropData
void SetDmgModBullet( float flDmgMod ) { m_flDmgModBullet = flDmgMod; }
void SetDmgModClub( float flDmgMod ) { m_flDmgModClub = flDmgMod; }
void SetDmgModExplosive( float flDmgMod ) { m_flDmgModExplosive = flDmgMod; }
float GetDmgModBullet( void ) { return m_flDmgModBullet; }
float GetDmgModClub( void ) { return m_flDmgModClub; }
float GetDmgModExplosive( void ) { return m_flDmgModExplosive; }
void SetExplosiveRadius( float flRadius ) { m_explodeRadius = flRadius; }
void SetExplosiveDamage( float flDamage ) { m_explodeDamage = flDamage; }
float GetExplosiveRadius( void ) { return m_explodeRadius; }
float GetExplosiveDamage( void ) { return m_explodeDamage; }
void SetPhysicsDamageTable( string_t iszTableName ) { m_iszPhysicsDamageTableName = iszTableName; }
string_t GetPhysicsDamageTable( void ) { return m_iszPhysicsDamageTableName; }
void SetBreakableModel( string_t iszModel ) { m_iszBreakableModel = iszModel; }
string_t GetBreakableModel( void ) { return m_iszBreakableModel; }
void SetBreakableSkin( int iSkin ) { m_iBreakableSkin = iSkin; }
int GetBreakableSkin( void ) { return m_iBreakableSkin; }
void SetBreakableCount( int iCount ) { m_iBreakableCount = iCount; }
int GetBreakableCount( void ) { return m_iBreakableCount; }
void SetMaxBreakableSize( int iSize ) { m_iMaxBreakableSize = iSize; }
int GetMaxBreakableSize( void ) { return m_iMaxBreakableSize; }
void SetPropDataBlocksLOS( bool bBlocksLOS ) { m_bBlockLOSSetByPropData = true; SetBlocksLOS( bBlocksLOS ); }
void SetPropDataIsAIWalkable( bool b ) { m_bIsWalkableSetByPropData = true; SetAIWalkable( b ); }
void SetBasePropData( string_t iszBase ) { m_iszBasePropData = iszBase; }
string_t GetBasePropData( void ) { return m_iszBasePropData; }
void SetInteraction( propdata_interactions_t Interaction ) { m_iInteractions |= (1 << Interaction); }
bool HasInteraction( propdata_interactions_t Interaction ) { return ( m_iInteractions & (1 << Interaction) ) != 0; }
void SetPhysicsMode(int iMode);
int GetPhysicsMode() { return m_iPhysicsMode; }
void SetMultiplayerBreakMode( mp_break_t mode ) {}
mp_break_t GetMultiplayerBreakMode( void ) const { return MULTIPLAYER_BREAK_DEFAULT; }
// static management fucntions:
static void RecreateAll(); // recreate all clientside props in map
static void DestroyAll(); // clear all clientside created phys props
static C_PhysPropClientside *CreateNew(bool bForce = false);
protected:
static void ParseAllEntities(const char *pMapData);
static const char *ParseEntity( const char *pEntData );
static void InitializePropRespawnZones(void);
public:
int m_iPhysicsMode; // should always be PHYSICS_MULTIPLAYER_CLIENTSIDE
float m_flTouchDelta; // Amount of time that must pass before another touch function can be called
float m_fDeathTime; // Point at which this object self destructs.
// The default of -1 indicates the object shouldn't destruct.
// properties from serverclass CPhysicsProp
float m_impactEnergyScale;
int m_spawnflags;
float m_inertiaScale;
protected:
// Prop data storage
float m_flDmgModBullet;
float m_flDmgModClub;
float m_flDmgModExplosive;
string_t m_iszPhysicsDamageTableName;
string_t m_iszBreakableModel;
int m_iBreakableSkin;
int m_iBreakableCount;
int m_iMaxBreakableSize;
string_t m_iszBasePropData;
int m_iInteractions;
float m_explodeDamage;
float m_explodeRadius;
bool m_bBlockLOSSetByPropData;
bool m_bIsWalkableSetByPropData;
// Count of how many pieces we'll break into, custom or generic
int m_iNumBreakableChunks;
C_FuncPhysicsRespawnZone *m_pRespawnZone;
};
//-----------------------------------------------------------------------------
// Purpose: A clientside zone that respawns physics props in it when the player leaves the PVS
//-----------------------------------------------------------------------------
class C_FuncPhysicsRespawnZone : public C_BaseEntity
{
DECLARE_CLASS( C_FuncPhysicsRespawnZone, C_BaseEntity );
public:
C_FuncPhysicsRespawnZone( void );
~C_FuncPhysicsRespawnZone( void );
bool KeyValue( const char *szKeyName, const char *szValue );
bool Initialize( void );
void InitializePropsWithin( void );
void PropDestroyed( C_PhysPropClientside *pProp );
bool CanMovePropAt( Vector vecOrigin, const Vector &vecMins, const Vector &vecMaxs );
void RespawnProps( void );
void ClientThink( void );
private:
struct clientsideproprespawn_t
{
string_t iszModelName;
Vector vecOrigin;
QAngle vecAngles;
int iSkin;
int iHealth;
int iSpawnFlags;
ClientEntityHandle_t hClientEntity;
};
CUtlVector<clientsideproprespawn_t> m_PropList;
};
#endif // PHYSPROPCLIENTSIDE_H
|