ScummVM API documentation
GameObject.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_GAME_OBJECT_H
29 #define GAME_GAME_OBJECT_H
30 
31 #include "hpl1/engine/engine.h"
32 #include "hpl1/penumbra-overture/GameEntity.h"
33 
34 using namespace hpl;
35 
36 //-----------------------------------------
37 
38 class iGameEnemy;
39 
40 //-----------------------------------------
41 
43  kSerializableClassInit(cGameObject_SaveData);
44 
45 public:
46  eObjectInteractMode mInteractMode;
47 
48  iGameEntity *CreateEntity();
49 };
50 
51 //------------------------------------------
52 class cGameObject;
53 
55 public:
56  cGameObjectBodyCallback(cInit *apInit, cGameObject *apObject);
57 
58  bool OnBeginCollision(iPhysicsBody *apBody, iPhysicsBody *apCollideBody);
59  void OnCollide(iPhysicsBody *apBody, iPhysicsBody *apCollideBody, cPhysicsContactData *apContactData);
60 
61  cInit *mpInit;
62 
63  cGameObject *mpObject;
64 };
65 
66 //--------------------------------------
67 
69 public:
71  mbActive = false;
72  }
73 
74  bool mbActive;
75 
76  float mfMinTime;
77  float mfMaxTime;
78 
79  float mfTime;
80  float mfMinDistance;
81 
82  float mfMinCloseDistance;
83 };
84 
85 //--------------------------------------
86 
88 public:
90  mbActive = false;
91  }
92 
93  bool mbActive;
94 
95  tString msEntity;
96  tString msSound;
97  tString msPS;
98  float mfMinImpulse;
99  float mfMinNormalSpeed;
100  float mfMinPlayerImpulse;
101  float mfCenterForce;
102 
103  bool mbExplosion;
104  float mfExpl_Radius;
105  float mfExpl_MinDamage;
106  float mfExpl_MaxDamage;
107  float mfExpl_MinForce;
108  float mfExpl_MaxForce;
109  float mfExpl_MaxImpulse;
110  float mfExpl_MinMass;
111  int mlExpl_Strength;
112 
113  bool mbLightFlash;
114  cColor mLight_Color;
115  float mfLight_Radius;
116  float mfLight_AddTime;
117  float mfLight_NegTime;
118  cVector3f mvLight_Offset;
119 
120  bool mbEarRing;
121  float mfEarRing_MaxDist;
122  float mfEarRing_Time;
123 };
124 
125 //--------------------------------------
126 
128 public:
130  mbActive = false;
131  }
132 
133  bool mbActive;
134  float mfDistance;
135  tStringVec mvSubtypes;
136 
137  bool mbIsEaten;
138  float mfEatLength;
139 };
140 
141 //--------------------------------------
142 
144 public:
146  mbActive = false;
147  }
148 
149  bool mbActive;
150  float mfMinLinearDamageSpeed;
151  float mfMinAngularDamageSpeed;
152  float mfMaxLinearDamageSpeed;
153  float mfMaxAngularDamageSpeed;
154  float mfMinDamage;
155  float mfMaxDamage;
156  int mlDamageStrength;
157 };
158 
159 //--------------------------------------
160 
161 class cGameObject : public iGameEntity {
162  typedef iGameEntity super;
163  friend class cEntityLoader_GameObject;
164  friend class cGameObjectBodyCallback;
165 
166 public:
167  cGameObject(cInit *apInit, const tString &asName);
168  ~cGameObject(void);
169 
170  void OnPlayerInteract();
171  void OnPlayerPick();
172 
173  bool IsSaved() {
174  if (mDisappearProps.mbActive)
175  return false;
176  return mbIsSaved;
177  }
178 
179  void Update(float afTimeStep);
180 
181  void BreakAction();
182 
183  void OnDeath(float afDamage);
184 
185  bool IsBreakable() { return mBreakProps.mbActive; }
186 
187  void OnPlayerGravityCollide(iCharacterBody *apCharBody, cCollideData *apCollideData);
188 
189  void SetInteractMode(eObjectInteractMode aInteractMode);
190  eObjectInteractMode GetInteractMode() { return mInteractMode; }
191 
192  void SetupBreakObject();
193 
194  bool IsDestroyable() { return mbDestroyable; }
195  float GetDestroyStrength() { return mfDestroyStrength; }
196  const tString &GetDestroySound() { return msDestoySound; }
197 
198  void SetupForceOffset();
199 
200  // SaveObject implementation
201  iGameEntity_SaveData *CreateSaveData();
202  void SaveToSaveData(iGameEntity_SaveData *apSaveData);
203  void LoadFromSaveData(iGameEntity_SaveData *apSaveData);
204 
205 private:
206  void GrabObject();
207 
208  void MoveObject();
209  float GetMoveDist();
210 
211  void PushObject();
212  float GetPushDist();
213 
214  void UpdateAttraction(float afTimeStep);
215  Hpl1::Std::set<iGameEnemy *> m_setAttractedEnemies;
216  iGameEnemy *mpCurrentAttraction;
217  float mfAttractCount;
218 
219  eObjectInteractMode mInteractMode;
220 
221  float mfForwardUpMul;
222  float mfForwardRightMul;
223 
224  float mfUpMul;
225  float mfRightMul;
226 
227  bool mbPickAtPoint;
228  bool mbRotateWithPlayer;
229 
230  bool mbUseNormalMass;
231  float mfGrabMassMul;
232 
233  bool mbCanBeThrown;
234  bool mbCanBePulled;
235 
236  bool mbIsMover;
237 
238  bool mbDestroyable;
239  float mfDestroyStrength;
240  tString msDestoySound;
241 
242  bool mbForceLightOffset;
243  cVector3f mvLightOffset;
244  tMatrixfVec mvLightLocalOffsets;
245 
246  float mfHapticTorqueMul;
247 
248  float mfCloseToSameCount;
249 
250  cObjectBreakProperties mBreakProps;
251 
252  cObjectDisappearProperties mDisappearProps;
253 
254  cObjectAttractProperties mAttractProps;
255 
256  cObjectDamageProperties mDamageProps;
257 
258  cGameObjectBodyCallback *mpBodyCallback;
259 };
260 
261 //--------------------------------------
262 
264 public:
265  cEntityLoader_GameObject(const tString &asName, cInit *apInit);
267 
268  static eObjectInteractMode ToInteractMode(const char *apString);
269 
270 private:
271  void BeforeLoad(TiXmlElement *apRootElem, const cMatrixf &a_mtxTransform, cWorld3D *apWorld);
272  void AfterLoad(TiXmlElement *apRootElem, const cMatrixf &a_mtxTransform, cWorld3D *apWorld);
273 
274  cInit *mpInit;
275 };
276 
277 #endif // GAME_GAME_OBJECT_H
Definition: AI.h:36
Definition: GameObject.h:263
Definition: str.h:59
Definition: GameObject.h:87
Definition: GameObject.h:68
Definition: GameObject.h:161
Definition: GameEntity.h:76
Definition: PhysicsBody.h:49
Definition: GameObject.h:143
Definition: GameObject.h:127
Definition: PhysicsBody.h:117
Definition: World3D.h:179
Definition: CollideData.h:46
Definition: GameObject.h:42
Definition: PhysicsMaterial.h:58
Definition: Color.h:37
Definition: CharacterBody.h:153
Definition: EntityLoader_Object.h:52
Definition: tinyxml.h:864
Definition: GameObject.h:54
Definition: GameEnemy.h:189
Definition: GameEntity.h:126
Definition: Init.h:70