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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Workfile: $
// $Date: $
// $NoKeywords: $
//===========================================================================//
#include "cbase.h"
#include "c_basetempentity.h"
#include "c_te_legacytempents.h"
#include "tier1/KeyValues.h"
#include "toolframework_client.h"
#include "tier0/vprof.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// Purpose: Breakable Model TE
//-----------------------------------------------------------------------------
class C_TEPhysicsProp : public C_BaseTempEntity
{
public:
DECLARE_CLASS( C_TEPhysicsProp, C_BaseTempEntity );
DECLARE_CLIENTCLASS();
C_TEPhysicsProp( void );
virtual ~C_TEPhysicsProp( void );
virtual void PostDataUpdate( DataUpdateType_t updateType );
public:
Vector m_vecOrigin;
QAngle m_angRotation;
Vector m_vecVelocity;
int m_nModelIndex;
int m_nSkin;
int m_nFlags;
int m_nEffects;
};
//-----------------------------------------------------------------------------
// Networking
//-----------------------------------------------------------------------------
IMPLEMENT_CLIENTCLASS_EVENT_DT(C_TEPhysicsProp, DT_TEPhysicsProp, CTEPhysicsProp)
RecvPropVector( RECVINFO(m_vecOrigin)),
RecvPropFloat( RECVINFO( m_angRotation[0] ) ),
RecvPropFloat( RECVINFO( m_angRotation[1] ) ),
RecvPropFloat( RECVINFO( m_angRotation[2] ) ),
RecvPropVector( RECVINFO(m_vecVelocity)),
RecvPropInt( RECVINFO(m_nModelIndex)),
RecvPropInt( RECVINFO(m_nFlags)),
RecvPropInt( RECVINFO(m_nSkin)),
RecvPropInt( RECVINFO(m_nEffects)),
END_RECV_TABLE()
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_TEPhysicsProp::C_TEPhysicsProp( void )
{
m_vecOrigin.Init();
m_angRotation.Init();
m_vecVelocity.Init();
m_nModelIndex = 0;
m_nSkin = 0;
m_nFlags = 0;
m_nEffects = 0;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_TEPhysicsProp::~C_TEPhysicsProp( void )
{
}
//-----------------------------------------------------------------------------
// Recording
//-----------------------------------------------------------------------------
static inline void RecordPhysicsProp( const Vector& start, const QAngle &angles,
const Vector& vel, int nModelIndex, bool bBreakModel, int nSkin, int nEffects )
{
if ( !ToolsEnabled() )
return;
if ( clienttools->IsInRecordingMode() )
{
const model_t* pModel = (nModelIndex != 0) ? modelinfo->GetModel( nModelIndex ) : NULL;
const char *pModelName = pModel ? modelinfo->GetModelName( pModel ) : "";
KeyValues *msg = new KeyValues( "TempEntity" );
msg->SetInt( "te", TE_PHYSICS_PROP );
msg->SetString( "name", "TE_PhysicsProp" );
msg->SetFloat( "time", gpGlobals->curtime );
msg->SetFloat( "originx", start.x );
msg->SetFloat( "originy", start.y );
msg->SetFloat( "originz", start.z );
msg->SetFloat( "anglesx", angles.x );
msg->SetFloat( "anglesy", angles.y );
msg->SetFloat( "anglesz", angles.z );
msg->SetFloat( "velx", vel.x );
msg->SetFloat( "vely", vel.y );
msg->SetFloat( "velz", vel.z );
msg->SetString( "model", pModelName );
msg->SetInt( "breakmodel", bBreakModel );
msg->SetInt( "skin", nSkin );
msg->SetInt( "effects", nEffects );
ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
msg->deleteThis();
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void TE_PhysicsProp( IRecipientFilter& filter, float delay,
int modelindex, int skin, const Vector& pos, const QAngle &angles, const Vector& vel, bool breakmodel, int effects )
{
tempents->PhysicsProp( modelindex, skin, pos, angles, vel, breakmodel, effects );
RecordPhysicsProp( pos, angles, vel, modelindex, breakmodel, skin, effects );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_TEPhysicsProp::PostDataUpdate( DataUpdateType_t updateType )
{
VPROF( "C_TEPhysicsProp::PostDataUpdate" );
tempents->PhysicsProp( m_nModelIndex, m_nSkin, m_vecOrigin, m_angRotation, m_vecVelocity, m_nFlags, m_nEffects );
RecordPhysicsProp( m_vecOrigin, m_angRotation, m_vecVelocity, m_nModelIndex, m_nFlags, m_nSkin, m_nEffects );
}
void TE_PhysicsProp( IRecipientFilter& filter, float delay, KeyValues *pKeyValues )
{
Vector vecOrigin, vecVel;
QAngle angles;
int nSkin;
nSkin = pKeyValues->GetInt( "skin", 0 );
vecOrigin.x = pKeyValues->GetFloat( "originx" );
vecOrigin.y = pKeyValues->GetFloat( "originy" );
vecOrigin.z = pKeyValues->GetFloat( "originz" );
angles.x = pKeyValues->GetFloat( "anglesx" );
angles.y = pKeyValues->GetFloat( "anglesy" );
angles.z = pKeyValues->GetFloat( "anglesz" );
vecVel.x = pKeyValues->GetFloat( "velx" );
vecVel.y = pKeyValues->GetFloat( "vely" );
vecVel.z = pKeyValues->GetFloat( "velz" );
const char *pModelName = pKeyValues->GetString( "model" );
int nModelIndex = pModelName[0] ? modelinfo->GetModelIndex( pModelName ) : 0;
bool bBreakModel = pKeyValues->GetInt( "breakmodel" ) != 0;
int nEffects = pKeyValues->GetInt( "effects" );
TE_PhysicsProp( filter, delay, nModelIndex, nSkin, vecOrigin, angles, vecVel, bBreakModel, nEffects );
}
|