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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "c_baseanimating.h"
class C_DODBaseRocket : public C_BaseAnimating
{
public:
DECLARE_CLASS( C_DODBaseRocket, C_BaseAnimating );
DECLARE_CLIENTCLASS();
C_DODBaseRocket();
virtual ~C_DODBaseRocket();
virtual void Spawn();
virtual int DrawModel( int flags );
virtual void PostDataUpdate( DataUpdateType_t type );
private:
CNetworkVector( m_vInitialVelocity );
float m_flSpawnTime;
};
IMPLEMENT_CLIENTCLASS_DT(C_DODBaseRocket, DT_DODBaseRocket, CDODBaseRocket)
RecvPropVector( RECVINFO( m_vInitialVelocity ) )
END_RECV_TABLE()
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_DODBaseRocket::C_DODBaseRocket()
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_DODBaseRocket::~C_DODBaseRocket()
{
ParticleProp()->StopEmission();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_DODBaseRocket::Spawn()
{
m_flSpawnTime = gpGlobals->curtime;
BaseClass::Spawn();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_DODBaseRocket::PostDataUpdate( DataUpdateType_t type )
{
BaseClass::PostDataUpdate( type );
if ( type == DATA_UPDATE_CREATED )
{
// Now stick our initial velocity into the interpolation history
CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator();
interpolator.ClearHistory();
float changeTime = GetLastChangeTime( LATCH_SIMULATION_VAR );
// Add a sample 1 second back.
Vector vCurOrigin = GetLocalOrigin() - m_vInitialVelocity;
interpolator.AddToHead( changeTime - 1.0, &vCurOrigin, false );
// Add the current sample.
vCurOrigin = GetLocalOrigin();
interpolator.AddToHead( changeTime, &vCurOrigin, false );
// do the same for angles
CInterpolatedVar< QAngle > &rotInterpolator = GetRotationInterpolator();
rotInterpolator.ClearHistory();
// Add a rotation sample 1 second back
QAngle vCurAngles = GetLocalAngles();
rotInterpolator.AddToHead( changeTime - 1.0, &vCurAngles, false );
// Add the current rotation
rotInterpolator.AddToHead( changeTime - 1.0, &vCurAngles, false );
int iAttachment = 1; //LookupAttachment( "smoke" ); // don't do bone access at this time, we know it's 1.
ParticleProp()->Create( "rockettrail", PATTACH_POINT_FOLLOW, iAttachment );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int C_DODBaseRocket::DrawModel( int flags )
{
// During the first half-second of our life, don't draw ourselves
if ( gpGlobals->curtime - m_flSpawnTime < 0.2 )
{
return 0;
}
return BaseClass::DrawModel( flags );
}
|