ScummVM API documentation
World2D.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 HPL1 Engine.
26  */
27 
28 #ifndef HPL_WORLD2D_H
29 #define HPL_WORLD2D_H
30 
31 #include "hpl1/engine/game/GameTypes.h"
32 #include "hpl1/engine/graphics/GraphicsTypes.h"
33 #include "hpl1/engine/math/MathTypes.h"
34 #include "hpl1/engine/system/SystemTypes.h"
35 
36 #include "hpl1/engine/scene/SoundSource.h"
37 #include "common/stablemap.h"
38 
39 class TiXmlElement;
40 
41 namespace hpl {
42 
43 class cGraphics;
44 class cResources;
45 class cSound;
46 
47 class iCamera;
48 class cCamera2D;
49 class cTileMap;
50 class cTile;
51 class cNode2D;
52 class cBody2D;
53 class cCollider2D;
54 class cGridMap2D;
55 class cLight2DPoint;
56 class iLight2D;
57 class cImageEntity;
58 class cParticleManager;
59 class cArea2D;
60 class iScript;
61 class cMesh2D;
62 class iParticleSystem2D;
63 
64 class cWorld2D {
65  friend class cCollider2D;
66 
67 public:
68  cWorld2D(tString asName, cGraphics *apGraphics, cResources *apResources, cSound *apSound, cCollider2D *apCollider);
69  ~cWorld2D();
70 
71  tString GetName() { return msName; }
72 
73  bool CreateFromFile(tString asFile);
74 
75  void Render(cCamera2D *apCamera);
76 
77  void Update(float afTimeStep);
78 
79  cVector2f GetWorldSize() { return mvWorldSize; }
80 
81  iScript *GetScript() { return mpScript; }
82 
83  void ResetBodyIDCount() { mlBodyIDCount = 0; }
84 
86 
87  cLight2DPoint *CreateLightPoint(tString asName = "");
88  void DestroyLight(iLight2D *apLight);
89  cGridMap2D *GetGridMapLights();
90  iLight2D *GetLight(const tString &asName);
91 
93 
94  cBody2D *CreateBody2D(const tString &asName, cMesh2D *apMesh, cVector2f avSize);
95  cGridMap2D *GetGridMapBodies() { return mpMapBodies; }
96 
98  cGridMap2D *GetGridMapAreas() { return mpMapAreas; }
99 
106  cArea2D *GetArea(const tString &asName, const tString &asType);
107 
109 
110  cSoundSource *CreateSoundSource(const tString &asName, const tString &asSoundName, bool abVolatile);
111  void DestroySoundSource(cSoundSource *apSound);
112 
114 
115  cImageEntity *CreateImageEntity(tString asName, tString asDataName);
116  cGridMap2D *GetGridMapImageEntities() { return mpMapImageEntities; }
117  void DestroyImageEntity(cImageEntity *apEntity);
118  cImageEntity *GetImageEntity(const tString &asName);
119 
121 
122  iParticleSystem2D *CreateParticleSystem(const tString &asName, const cVector3f &avSize);
123  void DestroyParticleSystem(iParticleSystem2D *apPS);
124 
126 
127  cTileMap *GetTileMap() { return mpTileMap; }
128  // Test!
129  void CreateTileMap();
130 
132  cNode2D *GetRootNode() { return mpRootNode; }
133 
134 private:
135  tString msName;
136  cGraphics *mpGraphics;
137  cSound *mpSound;
138  cResources *mpResources;
139  cCollider2D *mpCollider;
140 
141  cVector2f mvWorldSize;
142 
143  iScript *mpScript;
144 
145  cGridMap2D *mpMapLights;
146  cGridMap2D *mpMapImageEntities;
147  cGridMap2D *mpMapBodies;
148  cGridMap2D *mpMapParticles;
149  cGridMap2D *mpMapAreas;
150 
151  tSoundSourceList mlstSoundSources;
152 
153  int mlBodyIDCount;
154 
155  cTileMap *mpTileMap;
156  cNode2D *mpRootNode;
157 
158  tString msMapName;
159  float mfLightZ;
160  cColor mAmbientColor;
161 
162  // Update
163  void UpdateEntities();
164  void UpdateBodies();
165  void UpdateParticles();
166  void UpdateSoundSources();
167  void UpdateLights();
168 
169  // Render
170  void RenderImagesEntities(cCamera2D *apCamera);
171  void RenderParticles(cCamera2D *apCamera);
172 
173  // Load helper
174  int LoadTileData(cTile *apTile, tString *asData, int alStart);
175 };
176 
177 } // namespace hpl
178 
179 #endif // HPL_WOLRD2D_H
Definition: AI.h:36
Definition: Script.h:223
Definition: str.h:59
Definition: Light2DPoint.h:35
Definition: Tile.h:41
cNode2D * GetRootNode()
NODE METHODS //////////////////////.
Definition: World2D.h:132
Definition: Light2D.h:40
cArea2D * GetArea(const tString &asName, const tString &asType)
Definition: list.h:44
Definition: Body2D.h:49
Definition: Sound.h:40
Definition: Collider2D.h:48
Definition: GridMap2D.h:147
Definition: Node2D.h:37
Definition: Mesh2d.h:68
Definition: World2D.h:64
Definition: Resources.h:160
Definition: SoundSource.h:42
Definition: Color.h:37
Definition: Area2D.h:39
Definition: tinyxml.h:864
Definition: Graphics.h:46
Definition: Camera2D.h:38
Definition: TileMap.h:47
Definition: ImageEntity.h:44