ScummVM API documentation
PlayerHelper.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of Penumbra Overture.
26  */
27 
28 #ifndef GAME_PLAYER_HELPER_H
29 #define GAME_PLAYER_HELPER_H
30 
31 #include "hpl1/engine/engine.h"
32 
33 using namespace hpl;
34 
35 #include "hpl1/penumbra-overture/GameTypes.h"
36 
37 class cInit;
38 class cPlayer;
39 
40 //---------------------------------------------
41 
43 public:
44  virtual ~iPlayerWeaponCallback() = default;
45  virtual tString GetModelFile() = 0;
46  virtual cMatrixf GetOffsetMatrix() = 0;
47 
48  virtual void OnAttackDown() = 0;
49  virtual void OnAttackUp() = 0;
50 };
51 
52 //---------------------------------------------
53 
55 public:
57 
58  void Clear();
59  void Reset();
60 
61  void OnWorldExit();
62 
63  bool OnIntersect(iPhysicsBody *pBody, cPhysicsRayParams *apParams);
64 
65  bool mbOnGround;
66  iPhysicsMaterial *mpMaterial;
67  float mfMinDist;
68 };
69 
70 //---------------------------------------------
71 
73 public:
75 
76  void OnWorldExit();
77 
78  void Clear();
79 
80  bool OnIntersect(iPhysicsBody *pBody, cPhysicsRayParams *apParams);
81 
82  void CalculateResults();
83 
84  iPhysicsBody *mpPickedBody;
85  iPhysicsBody *mpPickedAreaBody;
86 
87  float mfMaxDistance;
88 
89  float mfPickedDist;
90  float mfPickedAreaDist;
91 
92  eGameEntityType mLastEntityType;
93 
94  cVector3f mvPickedPos;
95  cVector3f mvPickedAreaPos;
96 
97  float mfMinStaticDist;
98 };
99 
100 //---------------------------------------------
101 
103 public:
104  cPlayerHeadMove(cPlayer *apPlayer);
105 
106  void Update(float afTimeStep);
107 
108  void Start();
109  void Stop();
110 
111  float GetPos();
112 
113  bool IsActive() { return mbActive; }
114  float GetPosition() { return mfPos; }
115  float GetClimbPosition() { return mfClimbPos; }
116  float GetClimbCount() { return mfClimbCount; }
117 
118  float mfMaxHeadMove;
119  float mfMinHeadMove;
120  float mfHeadMoveSpeed;
121  float mfHeadMoveBackSpeed;
122 
123  float mfFootStepMul;
124 
125 private:
126  float mfAdd;
127  float mfPos;
128  bool mbActive;
129  bool mbFootStepped;
130  bool mbWasActive;
131 
132  float mfClimbCount;
133  float mfClimbPos;
134 
135  cPlayer *mpPlayer;
136 };
137 
138 //---------------------------------------------
139 
141 public:
142  cPlayerHealth(cInit *apInit);
143 
144  void Reset();
145 
146  void Update(float afTimeStep);
147 
148  void Draw();
149 
150 private:
151  cInit *mpInit;
152  cGraphicsDrawer *mpDrawer;
153 
154  float mfTimeCount;
155  float mfGfxAlpha;
156  float mfGfxAlphaAdd;
157  float mfGfxGlobalAlpha;
158 
159  cSoundEntry *mpSoundEntry;
160  float mfTerrorCheckCount;
161  int mlTerrorLevel;
162 
163  cGfxObject *mpDamageGfx;
164 };
165 
166 //---------------------------------------------
167 
169 public:
170  cPlayerEarRing(cInit *apInit, cPlayer *apPlayer);
171 
172  void Update(float afTimeStep);
173 
174  void Start(float afTime);
175  void Stop(bool abStopDirectly);
176 
177  void Reset();
178 
179 private:
180  cInit *mpInit;
181  cPlayer *mpPlayer;
182 
183  cSoundEntry *mpSoundEntry;
184 
185  float mfTimeCount;
186  float mfDeafTime;
187  bool mbDeaf;
188 };
189 
190 //---------------------------------------------
191 
193 public:
194  cPlayerLean(cInit *apInit, cPlayer *apPlayer);
195 
196  void OnWorldLoad();
197 
198  void Update(float afTimeStep);
199 
200  void Lean(float afMul, float afTimeStep);
201 
202  bool OnIntersect(iPhysicsBody *pBody, cPhysicsRayParams *apParams);
203 
204  void Reset();
205 
206  float mfDir;
207  float mfMovement;
208  float mfRotation;
209 
210 private:
211  cPlayer *mpPlayer;
212  cInit *mpInit;
213 
214  iCollideShape *mpHeadShape;
215 
216  float mfMaxMovement;
217  float mfMaxRotation;
218  float mfMaxTime;
219 
220  float mfMoveSpeed;
221 
222  bool mbIntersect;
223 
224  bool mbPressed;
225 };
226 
227 //---------------------------------------------
228 
230 public:
231  cPlayerDamage(cInit *apInit);
232  ~cPlayerDamage();
233 
234  void Start(float afSize, ePlayerDamageType aType);
235 
236  void Update(float afTimeStep);
237 
238  void Draw();
239 
240 private:
241  bool mbActive;
242 
243  float mfAlpha;
244  float mfAlphaAdd;
245 
246  cVector2f mvHeadSwingAcc;
247  cVector2f mvHeadSwingSpeed;
248 
249  float mfSize;
250 
251  cGfxObject *mvHitGfx[ePlayerDamageType_LastEnum];
252 
253  ePlayerDamageType mType;
254 
255  cInit *mpInit;
256  cGraphicsDrawer *mpDrawer;
257  cRendererPostEffects *mpPostEffects;
258 };
259 
260 //---------------------------------------------
261 
263 public:
264  cPlayerDeath(cInit *apInit);
265  ~cPlayerDeath();
266 
267  void Reset();
268 
269  void Start();
270 
271  void Update(float afTimeStep);
272 
273  void Draw();
274 
275  bool IsActive() { return mbActive; }
276 
277  float GetHeighAdd() { return mfHeightAdd; }
278 
279 private:
280  bool mbActive;
281 
282  float mfHeightAdd;
283  float mfRoll;
284 
285  float mfMinHeightAdd;
286 
287  cGfxObject *mpFadeGfx;
288  cGfxObject *mpBlackGfx;
289 
290  bool mbStartFade;
291  float mfFadeAlpha;
292  float mfBlackAlpha;
293 
294  cInit *mpInit;
295  cGraphicsDrawer *mpDrawer;
296  cRendererPostEffects *mpPostEffects;
297 };
298 
299 //---------------------------------------------
300 
302 public:
303  cPlayerFlashLight(cInit *apInit);
305 
306  void Reset();
307 
308  bool OnIntersect(iPhysicsBody *pBody, cPhysicsRayParams *apParams);
309 
310  void OnWorldLoad();
311 
312  void Update(float afTimeStep);
313 
314  void SetActive(bool abX);
315  bool IsActive() { return mbActive; }
316 
317  void SetDisabled(bool abX);
318  bool IsDisabled() { return mbDisabled; }
319 
320  void OnPostSceneDraw();
321 
322 private:
323  bool mbActive;
324 
325  bool mbDisabled;
326 
327  float mfAlpha;
328 
329  float mfFlickerTime;
330 
331  float mfRayCastTime;
332  float mfClosestDist;
333  iPhysicsBody *mpClosestBody;
334 
335  // iTexture *mpTextureCache;
336 
337  cInit *mpInit;
338 
339  cVector3f mvStart;
340  cVector3f mvEnd;
341 };
342 
343 //---------------------------------------------
344 
346 public:
347  cPlayerGlowStick(cInit *apInit);
348  ~cPlayerGlowStick();
349 
350  void Reset();
351 
352  void OnWorldLoad();
353  void Destroy();
354 
355  void Update(float afTimeStep);
356 
357  void SetActive(bool abX);
358  bool IsActive() { return mbActive; }
359 
360 private:
361  bool mbActive;
362 
363  cInit *mpInit;
364 };
365 
366 //---------------------------------------------
367 
368 class iHudModel;
370 public:
371  cPlayerFlare(cInit *apInit);
372  ~cPlayerFlare();
373 
374  void Reset();
375 
376  void OnWorldLoad();
377 
378  void Update(float afTimeStep);
379 
380  void SetActive(bool abX);
381  bool IsActive() { return mbActive; }
382 
383  float GetTime() { return mfTime; }
384  void SetTime(float afX) { mfTime = afX; }
385 
386 private:
387  bool mbActive;
388 
389  float mfTime;
390 
391  iLight3D *mpLight;
392  iHudModel *mpModel;
393 
394  float mfMaxLightRadius;
395  float mfLightRadius;
396  float mfLightPulse;
397  float mfLightPulseAdd;
398 
399  cInit *mpInit;
400 };
401 
402 //---------------------------------------------
403 
405 public:
406  cPlayerNoiseFilter(cInit *apInit);
408 
409  void Draw();
410 
411  void Update(float afTimeStep);
412 
413  void SetActive(bool abX);
414  bool IsActive() { return mbActive; }
415 
416 private:
417  bool mbActive;
418 
419  float mfAlpha;
420  float mfTimeCount;
421 
422  int mlAmount;
423 
424  // cLight3DPoint *mpLight;
425  // cMeshEntity *mpMeshEntity;
426 
427  cInit *mpInit;
428  cGraphicsDrawer *mpDrawer;
429 
430  Common::Array<cGfxObject *> mvGfxNoise;
431  tIntVec mvCurrentGfx;
432 };
433 
434 //---------------------------------------------
435 
437 public:
438  cPlayerFearFilter(cInit *apInit);
440 
441  void Draw();
442 
443  void Update(float afTimeStep);
444 
445  void Reset();
446 
447  void SetActive(bool abX);
448  bool IsActive() { return mbActive; }
449 
450 private:
451  bool mbActive;
452 
453  float mfAlpha;
454  float mfMaxAlpha;
455 
456  cInit *mpInit;
457 };
458 
459 //---------------------------------------------
460 
462 public:
463  cPlayerLookAt(cPlayer *apPlayer);
464  ~cPlayerLookAt();
465 
466  void Update(float afTimeStep);
467 
468  void Reset();
469 
470  void SetTarget(const cVector3f &avTargetPos, float afSpeedMul, float afMaxSpeed);
471 
472  void SetActive(bool abX);
473  bool IsActive() { return mbActive; }
474 
475 private:
476  bool mbActive;
477  cVector3f mvTargetPos;
478 
479  float mfSpeedMul;
480  float mfMaxSpeed;
481 
482  cPlayer *mpPlayer;
483 };
484 
485 //---------------------------------------------
486 
488 public:
489  cPlayerHidden(cInit *apInit);
490  ~cPlayerHidden();
491 
492  void Draw();
493 
494  void Update(float afTimeStep);
495 
496  void Reset();
497 
498  void OnWorldLoad();
499  void OnWorldExit();
500 
501  bool InShadows();
502  bool IsHidden() { return mbHidden; }
503  void UnHide();
504 
505  bool OnIntersect(iPhysicsBody *pBody, cPhysicsRayParams *apParams);
506 
507  bool HasLineOfSight(iLight3D *pLight, iPhysicsWorld *pPhysicsWorld);
508 
509 private:
510  void UpdateEnemyTooClose(float afTimeStep);
511 
512  cInit *mpInit;
513  cRenderer3D *mpRenderer;
514  cGraphicsDrawer *mpDrawer;
515  cSoundHandler *mpSoundHandler;
516 
517  cGfxObject *mpInShadowGfx;
518 
519  iLight3D *mpLight;
520 
521  float mfInShadowAlpha;
522  float mfInShadowPulse;
523  float mfInShadowPulseAdd;
524 
525  float mfStartAspect;
526  float mfHiddenAspect;
527  float mfAspect;
528  float mfAspectAdd;
529 
530  float mfStartFov;
531  float mfHiddenFov;
532  float mfFov;
533  float mfFovAdd;
534 
535  float mfStartEffectOffset;
536  float mfHiddenEffectOffset;
537  float mfEffectOffset;
538  float mfEffectOffsetAdd;
539 
540  float mfHiddenOnTime;
541  float mfHiddenOffTime;
542 
543  float mfCheckEnemyCloseCount;
544  float mfEnemyTooCloseCount;
545  float mfEnemyTooCloseMax;
546  bool mbEnemyTooClose;
547 
548  float mfCloseEffectFov;
549  float mfCloseEffectFovAdd;
550  float mfCloseEffectFovMax;
551  float mfCloseEffectFovMin;
552 
553  float mbInShadows;
554 
555  float mfUpdateCount;
556 
557  float mfLight;
558  float mfMaxLight;
559 
560  float mfHiddenCount;
561  float mfHiddenTime;
562  bool mbHidden;
563  float mfHiddenOnCount;
564 
565  bool mbIntersected;
566 
567  FontData *mpFont;
568 };
569 
570 //---------------------------------------------
571 
573 public:
574  cPlayerBodyCallback(cPlayer *apPlayer);
575  virtual ~cPlayerBodyCallback() = default;
576 
577  void OnHitGround(iCharacterBody *apCharBody, const cVector3f &avVel);
578  void OnGravityCollide(iCharacterBody *apCharBody, iPhysicsBody *apCollideBody,
579  cCollideData *apCollideData) {}
580 
581 private:
582  cPlayer *mpPlayer;
583 
584  float mfFallSpeed_Min;
585  float mfFallDamage_Min;
586  tString msFallSound_Min;
587 
588  float mfFallSpeed_Med;
589  float mfFallDamage_Med;
590  tString msFallSound_Med;
591 
592  float mfFallSpeed_Max;
593  float mfFallDamage_Max;
594  tString msFallSound_Max;
595 };
596 
597 //---------------------------------------------
598 
599 #endif // GAME_PLAYER_HELPER_H
Definition: AI.h:36
Definition: PlayerHelper.h:229
Definition: PlayerHelper.h:301
Definition: str.h:59
Definition: PhysicsWorld.h:92
Definition: PlayerHelper.h:487
Definition: array.h:52
Definition: Light3D.h:117
Definition: PlayerHelper.h:42
Definition: font_data.h:67
Definition: PhysicsWorld.h:100
Definition: PlayerHelper.h:345
Definition: PlayerHelper.h:572
Definition: PhysicsWorld.h:115
Definition: PlayerHelper.h:102
Definition: SoundHandler.h:71
Definition: Player.h:145
Definition: GraphicsDrawer.h:77
Definition: CollideShape.h:50
Definition: PlayerHelper.h:140
Definition: PlayerHelper.h:262
Definition: PlayerHelper.h:72
Definition: RendererPostEffects.h:71
Definition: GfxObject.h:38
Definition: PhysicsBody.h:117
Definition: Renderer3D.h:139
Definition: PlayerHelper.h:168
Definition: CollideData.h:46
Definition: PlayerHelper.h:192
Definition: PhysicsMaterial.h:77
Definition: PlayerHands.h:74
Definition: PlayerHelper.h:54
Definition: PlayerHelper.h:436
Definition: SoundHandler.h:122
Definition: PlayerHelper.h:404
Definition: PlayerHelper.h:461
Definition: CharacterBody.h:153
Definition: PlayerHelper.h:369
Definition: Init.h:70
Definition: CharacterBody.h:49