ScummVM API documentation
MapHandler.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_MAP_HANDLER_H
29#define GAME_MAP_HANDLER_H
30
31#include "hpl1/engine/engine.h"
32
33// Linux X11 Defines This
34#undef DestroyAll
35
36using namespace hpl;
37
38class cInit;
39class iGameEntity;
40class iGameEnemy;
42class cGameStickArea;
43class cSavedWorld;
44class cGameTimer;
45class cGameItem;
46
48typedef tGameEntityMap::iterator tGameEntityMapIt;
49
51typedef tGameEntityVec::iterator tGameEntityVecIt;
52
55
58
61
64
65//-----------------------------------------
66
68public:
69 bool mbActive;
70 tString msNewMap;
71 tString msPosName;
72 tString msDoneSound;
73 float mfFadeInTime;
74 tString msLoadTextCat;
75 tString msLoadTextEntry;
76};
77
78//-----------------------------------------
79
81public:
82 cWorldCache(cInit *apInit);
84
85 void AddResources();
86 void DecResources();
87
88 int GetCount() { return mlCount; }
89
90private:
91 cInit *mpInit;
92 cResources *mpResources;
93
94 int mlCount;
95
96 tResourceBaseList mlstMaterials;
97 tResourceBaseList mlstMeshes;
98 tResourceBaseList mlstAnimations;
99};
100
101//-----------------------------------------
102
104public:
105 tString msName;
106 double mfTime;
107};
108
109//-----------------------------------------
110
113
114//-----------------------------------------
115
117public:
118 cEffectLightFlash(cInit *apInit, const cVector3f &avPos, float afRadius, const cColor &aColor, float afAddTime, float afNegTime);
120
121 void Update(float afTimeStep);
122
123 bool IsDead() { return mbDead; }
124
125private:
126 cInit *mpInit;
127
128 iLight3D *mpLight;
129
130 float mfRadius;
131 float mfNegTime;
132
133 bool mbIsDying;
134
135 bool mbDead;
136};
137
140
141//-----------------------------------------
142
144public:
146
147 void OnStart(cSoundEntity *apSoundEntity);
148
149private:
150 cInit *mpInit;
151 tStringVec mvEnemyHearableSounds;
152};
153//-----------------------------------------
154
155class cMapHandler : public iUpdateable {
156 friend class cMapHandlerSoundCallback;
157
158public:
159 cMapHandler(cInit *apInit);
160 ~cMapHandler();
161
162 bool Load(const tString &asFile, const tString &asStartPos);
163 bool LoadSimple(const tString &asFile, bool abLoadEntities);
164
165 void ChangeMap(const tString &asMap, const tString &asPos, const tString &asStartSound,
166 const tString &asStopSound, float afFadeOutTime, float afFadeInTime,
167 tString asLoadTextCat, tString asLoadTextEntry);
168
169 void AddSaveData(cSavedWorld *apSavedWorld);
170 void LoadSaveData(cSavedWorld *apSavedWorld);
171
172 void DestroyAll();
173
174 void OnWorldLoad();
175 void OnStart();
176 void OnPostSceneDraw();
177 void Update(float afTimeStep);
178 void Reset();
179 void OnDraw();
180
181 cWorldCache *GetWorldCache() { return mpWorldCache; }
182
183 cGameTimer *CreateTimer(const tString &asName, float afTime, const tString &asCallback, bool abGlobal);
184 cGameTimer *GetTimer(const tString &asName);
185
186 void AddLightFlash(const cVector3f &avPos, float afRadius, const cColor &aColor, float afAddTime, float afNegTime);
187
188 void AddGameEnemy(iGameEnemy *apEnemy);
189 tGameEnemyIterator GetGameEnemyIterator();
190
191 void AddGameItem(cGameItem *apItem);
192 void RemoveGameItem(cGameItem *apItem);
193
194 void AddStickArea(cGameStickArea *apArea);
195 void RemoveStickArea(cGameStickArea *apArea);
196 cGameStickArea *GetBodyStickArea(iPhysicsBody *apBody);
197
198 void AddGameEntity(iGameEntity *apEntity);
199 void RemoveGameEntity(iGameEntity *apEntity);
200 iGameEntity *GetGameEntity(const tString &asName, bool abErrorMessage = true);
201 tGameEntityIterator GetGameEntityIterator();
202
203 iGameEntity *GetLatestEntity();
204 const tString &GetCurrentMapName() { return msCurrentMap; }
205 void SetCurrentMapName(const tString &asName) { msCurrentMap = asName; }
206 double GetGameTime() { return mfGameTime; }
207 bool IsPreUpdating() { return mbPreUpdating; }
208
209 void SetMapGameName(const tWString &asName) { msMapGameName = asName; }
210 tWString GetMapGameName() { return msMapGameName; }
211
212 bool IsDestroyingAll() { return mbDestroyingAll; }
213
214 bool IsChangingMap() { return mMapChanger.mbActive; }
215
217 // Saving
218 void SaveToGlobal(cMapHandler_GlobalSave *apSave);
219 void LoadFromGlobal(cMapHandler_GlobalSave *apSave);
220
221private:
222 void RenderItemEffect();
223
224 void PrintSoundsPlaying();
225
226 void PreUpdate(double afTimeSinceVisit);
227
228 double AddLoadedMap(cWorld3D *apWorld);
229
230 void UpdateTimers(float afTimeStep);
231 void RemoveLocalTimers();
232
233 double mfGameTime;
234
235 cInit *mpInit;
236
237 cScene *mpScene;
238 cResources *mpResources;
239
240 iTexture *mpMapChangeTexture;
241
242 cMapChanger mMapChanger;
243 cWorldCache *mpWorldCache;
244
245 iGameEntity *mpLatestEntity;
246 tString msCurrentMap;
247 tWString msMapGameName;
248
249 Common::Array<cLoadedMap> mvLoadedMaps;
250
251 tGameTimerList mlstTimers;
252
253 cMapHandlerSoundCallback *mpSoundCallback;
254
255 tGameEntityMap m_mapGameEntities;
256 tGameEnemyList mlstGameEnemies;
257 tGameItemList mlstGameItems;
258 tEffectLightFlashList mlstLightFlashes;
259 tGameStickAreaList mlstGameStickAreas;
260
261 bool mbPreUpdating;
262
263 bool mbDestroyingAll;
264};
265
266#endif // GAME_MAP_HANDLER_H
Definition: array.h:52
T * iterator
Definition: array.h:54
Definition: str.h:59
Definition: ustr.h:57
Definition: MapHandler.h:116
Definition: GameItem.h:62
Definition: GameStickArea.h:68
Definition: GameTypes.h:222
Definition: Init.h:70
Definition: MapHandler.h:103
Definition: MapHandler.h:67
Definition: SaveHandler.h:151
Definition: MapHandler.h:155
Definition: MapHandler.h:143
Definition: SaveHandler.h:239
Definition: MapHandler.h:80
Definition: Color.h:37
Definition: Resources.h:160
Definition: SystemTypes.h:411
Definition: SystemTypes.h:467
Definition: Scene.h:61
Definition: SoundEntity.h:86
Definition: World3D.h:179
Definition: Light3D.h:117
Definition: PhysicsBody.h:117
Definition: SoundEntity.h:75
Definition: Texture.h:88
Definition: Updateable.h:35
Definition: GameEnemy.h:189
Definition: GameEntity.h:126
Definition: list_intern.h:54