/
SpecialFX.h
150 lines (113 loc) · 3.64 KB
/
SpecialFX.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
// ----------------------------------------------------------------------- //
//
// MODULE : SpecialFX.h
//
// PURPOSE : Generic client-side Special FX wrapper class - Definition
//
// CREATED : 10/13/97
//
// (c) 1997-1999 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#ifndef __SPECIAL_FX_H__
#define __SPECIAL_FX_H__
#include "ltbasedefs.h"
#include "iltclient.h"
#include "SharedBaseFXStructs.h"
#include "SFXMsgIds.h"
#pragma warning( disable : 4786 )
#include <vector>
class CSpecialFX
{
public :
CSpecialFX()
{
m_bWantRemove = LTFALSE;
m_pClientDE = LTNULL;
m_hObject = LTNULL;
m_hServerObject = LTNULL;
m_fUpdateDelta = 0.001f;
m_fNextUpdateTime = 0.0f;
m_vLastServPos.Init();
m_vVel.Init();
m_nMenuLayer = 0;
}
virtual ~CSpecialFX()
{
CSpecialFX::Term();
}
virtual void Term()
{
if (m_pClientDE && m_hObject)
{
m_pClientDE->RemoveObject(m_hObject);
m_hObject = LTNULL;
}
}
virtual LTBOOL CreateObject(ILTClient* pClientDE)
{
if (!pClientDE) return LTFALSE;
m_pClientDE = pClientDE;
if (m_hServerObject)
{
m_pClientDE->GetObjectPos(m_hServerObject, &m_vLastServPos);
}
return LTTRUE;
}
virtual LTBOOL Init(HLOCALOBJ hServObj, ILTMessage_Read *pMsg)
{
if (!pMsg) return LTFALSE;
m_hServerObject = hServObj;
return LTTRUE;
}
virtual LTBOOL Init(SFXCREATESTRUCT* psfxCreateStruct)
{
if (!psfxCreateStruct) return LTFALSE;
m_hServerObject = psfxCreateStruct->hServerObj;
return LTTRUE;
}
// Return of LTFALSE indicates special fx is done and can be removed.
virtual LTBOOL Update()
{
// Calculate our server-object's velocity...
if (m_hServerObject && m_pClientDE)
{
LTVector vPos;
m_pClientDE->GetObjectPos(m_hServerObject, &vPos);
m_vVel = vPos - m_vLastServPos;
m_vVel /= m_pClientDE->GetFrameTime();
m_vLastServPos = vPos;
}
return LTTRUE;
}
virtual void Render(HOBJECT hCamera) {}
// Call this to tell special fx to finish up so we can remove it...
virtual void WantRemove(LTBOOL bRemove=LTTRUE)
{
m_bWantRemove = bRemove;
if (m_bWantRemove) m_hServerObject = LTNULL;
}
LTBOOL IsWaitingForRemove() const { return m_bWantRemove; }
HLOCALOBJ GetObject() const { return m_hObject; }
HLOCALOBJ GetServerObj() const { return m_hServerObject; }
LTFLOAT GetUpdateDelta() const { return m_fUpdateDelta; }
virtual void OnObjectRotate( LTRotation *pRot ) {}
virtual void HandleTouch(CollisionInfo *pInfo) {}
virtual void OnModelKey(HLOCALOBJ hObj, ArgList *pArgs) {}
virtual LTBOOL OnServerMessage(ILTMessage_Read *pMsg) { return (!!pMsg); }
LTFLOAT m_fNextUpdateTime; // When do we update next
// Function for returning a special effect ID from a derived class
virtual uint32 GetSFXID() { return SFX_TOTAL_NUMBER + 1; }
virtual uint8 GetMenuLayer() { return m_nMenuLayer; }
protected :
ILTClient* m_pClientDE;
HOBJECT m_hObject; // Special FX object
HOBJECT m_hServerObject; // Local handle to Server-side object
LTVector m_vLastServPos; // Last position of the server object
LTVector m_vVel; // Our server object's velocity
LTBOOL m_bWantRemove;
LTFLOAT m_fUpdateDelta; // Time between updates
uint8 m_nMenuLayer;
};
typedef std::vector<CSpecialFX *> SFXArray;
#endif // __SPECIAL_FX_H__