-
Notifications
You must be signed in to change notification settings - Fork 105
/
EffectHandler.h
299 lines (220 loc) · 5.8 KB
/
EffectHandler.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
/*
* Copyright (C) 2006-2010 - Frictional Games
*
* This file is part of Penumbra Overture.
*
* Penumbra Overture is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Penumbra Overture is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Penumbra Overture. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GAME_EFFECT_HANDLER_H
#define GAME_EFFECT_HANDLER_H
#include "StdAfx.h"
using namespace hpl;
class cInit;
//-----------------------------------------
class cEffect_Underwater
{
public:
cEffect_Underwater(cInit *apInit, cGraphicsDrawer *apDrawer);
~cEffect_Underwater();
void Update(float afTimeStep);
void OnDraw();
void Reset();
void SetActive(bool abX);
bool IsActive(){ return mbActive;}
void SetColor(const cColor &aColor){mColor = aColor;}
private:
cInit *mpInit;
cGraphicsDrawer *mpDrawer;
cGfxObject *mpWhiteGfx;
bool mbActive;
cColor mColor;
};
//-----------------------------------------
class cEffect_ShakeScreen_Shake
{
public:
float mfMaxSize;
float mfSize;
float mfTime;
float mfFadeInTime;
float mfMaxFadeInTime;
float mfFadeOutTime;
float mfMaxFadeOutTime;
};
class cEffect_ShakeScreen
{
public:
cEffect_ShakeScreen(cInit *apInit);
~cEffect_ShakeScreen();
void Start(float afAmount, float afTime, float afFadeInTime,float afFadeOutTime);
void Update(float afTimeStep);
void Reset();
cVector3f GetScreenAdd(){return mvAdd;}
private:
cInit *mpInit;
cVector3f mvAdd;
iHapticForce *mpForce;
std::list<cEffect_ShakeScreen_Shake> mlstShakes;
};
//-----------------------------------------
class cGameSaveArea;
class cEffect_SaveEffect
{
public:
cEffect_SaveEffect(cInit *apInit, cGraphicsDrawer *apDrawer);
~cEffect_SaveEffect();
void NormalSave(const cVector3f &avPos, cGameSaveArea *apSaveArea);
void AutoSave();
void Update(float afTimeStep);
void OnDraw();
void Reset();
private:
void NormalSaveUpdate(float afTimeStep);
void AutoSaveUpdate(float afTimeStep);
cInit *mpInit;
cGraphicsDrawer *mpDrawer;
cGfxObject *mpFlashGfx;
cGameSaveArea *mpSaveArea;
tWString msMessage;
bool mbActive;
int mlState;
bool mbAutoSave;
cVector3f mvPosition;
float mfFlashAlpha;
cColor mFlashColor;
float mfTime;
float mfStartFov;
float mfFov;
};
//-----------------------------------------
class cEffect_DepthOfField
{
public:
cEffect_DepthOfField(cInit *apInit);
~cEffect_DepthOfField();
void SetDisabled(bool abX);
bool IsDisabled(){ return mbDisabled;}
void SetActive(bool abX, float afFadeTime);
bool IsActive(){ return mbActive;}
void SetUp(float afNearPlane, float afFocalPlane, float afFarPlane);
void SetFocusBody(iPhysicsBody *apBody){mpFocusBody = apBody;}
void FocusOnBody(iPhysicsBody *apBody);
void Update(float afTimeStep);
void Reset();
private:
cInit *mpInit;
cRendererPostEffects *mpPostEffects;
iPhysicsBody *mpFocusBody;
bool mbActive;
bool mbDisabled;
float mfFadeSpeed;
float mfMaxBlur;
};
//-----------------------------------------
class cEffect_Flash
{
public:
cEffect_Flash(cInit *apInit, cGraphicsDrawer *apDrawer);
~cEffect_Flash();
void Start(float afFadeIn, float afWhite, float afFadeOut);
void Update(float afTimeStep);
void OnDraw();
void Reset();
private:
cInit *mpInit;
cGraphicsDrawer *mpDrawer;
cGfxObject *mpWhiteGfx;
bool mbActive;
float mfAlpha;
int mlStep;
float mfCount;
float mfFadeInSpeed;
float mfWhiteSpeed;
float mfFadeOutSpeed;
};
//-----------------------------------------
class cSubTitle
{
public:
tWString msMessage;
float mfCount;
float mfAlpha;
bool mbActive;
};
typedef std::list<cSubTitle> tSubTitleList;
typedef tSubTitleList::iterator tSubTitleListIt;
class cEffect_SubTitle
{
public:
cEffect_SubTitle(cInit *apInit, cGraphicsDrawer *apDrawer);
~cEffect_SubTitle();
void Add(const tWString& asMessage, float afTime, bool abRemovePrevious);
void Update(float afTimeStep);
void OnDraw();
void Reset();
private:
cInit *mpInit;
cGraphicsDrawer *mpDrawer;
iFontData *mpFont;
tSubTitleList mlstSubTitles;
};
//-----------------------------------------
class cEffect_WaveGravity
{
public:
cEffect_WaveGravity(cInit *apInit);
~cEffect_WaveGravity();
void SetActive(bool abX);
//alDir: 0=Xaxis 1=Zaxis
void Setup(float afMaxAngle, float afSwingLength, float afGravitySize, int alDir);
void Update(float afTimeStep);
void Reset();
private:
cInit *mpInit;
bool mbActive;
float mfMaxAngle;
float mfSwingLength;
float mfSize;
int mlDir;
float mfTime;
};
//-----------------------------------------
class cEffectHandler : public iUpdateable
{
public:
cEffectHandler(cInit *apInit);
~cEffectHandler();
void OnStart();
void Update(float afTimeStep);
void Reset();
void OnDraw();
cEffect_Flash* GetFlash(){ return mpFlash;}
cEffect_WaveGravity* GetWaveGravity(){ return mpWaveGravity;}
cEffect_SubTitle* GetSubTitle(){ return mpSubTitle;}
cEffect_DepthOfField* GetDepthOfField(){ return mpDepthOfField;}
cEffect_SaveEffect* GetSaveEffect(){ return mpSaveEffect;}
cEffect_ShakeScreen* GetShakeScreen(){ return mpShakeScreen;}
cEffect_Underwater* GetUnderwater(){ return mpUnderwater;}
private:
cInit *mpInit;
cGraphicsDrawer *mpDrawer;
cEffect_Flash *mpFlash;
cEffect_WaveGravity *mpWaveGravity;
cEffect_SubTitle *mpSubTitle;
cEffect_DepthOfField *mpDepthOfField;
cEffect_SaveEffect *mpSaveEffect;
cEffect_ShakeScreen *mpShakeScreen;
cEffect_Underwater *mpUnderwater;
};
#endif // GAME_EFFECT_HANDLER_H