@@ -28,6 +28,7 @@ GameObjectManager::GameObjectManager() :
28
28
m_gameobjects(),
29
29
m_gameobjects_new(),
30
30
m_solid_tilemaps(),
31
+ m_all_tilemaps(),
31
32
m_objects_by_name(),
32
33
m_objects_by_uid(),
33
34
m_objects_by_type_index(),
@@ -198,18 +199,7 @@ GameObjectManager::flush_game_objects()
198
199
}
199
200
}
200
201
}
201
- update_solids ();
202
- }
203
-
204
- void
205
- GameObjectManager::update_solids ()
206
- {
207
- m_solid_tilemaps.clear ();
208
- for (auto tilemap : get_objects_by_type_index (typeid (TileMap)))
209
- {
210
- TileMap* tm = static_cast <TileMap*>(tilemap);
211
- if (tm->is_solid ()) m_solid_tilemaps.push_back (tm);
212
- }
202
+ update_tilemaps ();
213
203
}
214
204
215
205
void
@@ -222,6 +212,20 @@ GameObjectManager::update_solid(TileMap* tm) {
222
212
m_solid_tilemaps.erase (it);
223
213
}
224
214
}
215
+
216
+ void
217
+ GameObjectManager::update_tilemaps ()
218
+ {
219
+ m_solid_tilemaps.clear ();
220
+ m_all_tilemaps.clear ();
221
+ for (auto tilemap : get_objects_by_type_index (typeid (TileMap)))
222
+ {
223
+ TileMap* tm = static_cast <TileMap*>(tilemap);
224
+ if (tm->is_solid ()) m_solid_tilemaps.push_back (tm);
225
+ m_all_tilemaps.push_back (tm);
226
+ }
227
+ }
228
+
225
229
void
226
230
GameObjectManager::this_before_object_add (GameObject& object)
227
231
{
@@ -270,8 +274,8 @@ float
270
274
GameObjectManager::get_width () const
271
275
{
272
276
float width = 0 ;
273
- for (auto & solids: get_solid_tilemaps ()) {
274
- width = std::max (width, solids ->get_bbox ().get_right ());
277
+ for (auto & tilemap: get_all_tilemaps ()) {
278
+ width = std::max (width, tilemap ->get_bbox ().get_right ());
275
279
}
276
280
277
281
return width;
@@ -281,8 +285,8 @@ float
281
285
GameObjectManager::get_height () const
282
286
{
283
287
float height = 0 ;
284
- for (const auto & solids: get_solid_tilemaps ()) {
285
- height = std::max (height, solids ->get_bbox ().get_bottom ());
288
+ for (const auto & tilemap: get_all_tilemaps ()) {
289
+ height = std::max (height, tilemap ->get_bbox ().get_bottom ());
286
290
}
287
291
288
292
return height;
@@ -292,9 +296,9 @@ float
292
296
GameObjectManager::get_tiles_width () const
293
297
{
294
298
float width = 0 ;
295
- for (const auto & solids : get_solid_tilemaps ()) {
296
- if (static_cast <float >(solids ->get_width ()) > width)
297
- width = static_cast <float >(solids ->get_width ());
299
+ for (const auto & tilemap : get_all_tilemaps ()) {
300
+ if (static_cast <float >(tilemap ->get_width ()) > width)
301
+ width = static_cast <float >(tilemap ->get_width ());
298
302
}
299
303
return width;
300
304
}
@@ -303,9 +307,9 @@ float
303
307
GameObjectManager::get_tiles_height () const
304
308
{
305
309
float height = 0 ;
306
- for (const auto & solids : get_solid_tilemaps ()) {
307
- if (static_cast <float >(solids ->get_height ()) > height)
308
- height = static_cast <float >(solids ->get_height ());
310
+ for (const auto & tilemap : get_all_tilemaps ()) {
311
+ if (static_cast <float >(tilemap ->get_height ()) > height)
312
+ height = static_cast <float >(tilemap ->get_height ());
309
313
}
310
314
return height;
311
315
}
0 commit comments