@@ -129,6 +129,26 @@ Projectile* GameObjectsManager::CreateProjectile(const glm::vec3& position, cxx:
129129 return instance;
130130}
131131
132+ Decoration* GameObjectsManager::CreateDecoration (const glm::vec3& position, cxx::angle_t heading, GameObjectStyle* desc)
133+ {
134+ Decoration* instance = nullptr ;
135+ debug_assert (gGameMap .mStyleData .IsLoaded ());
136+ debug_assert (desc);
137+ debug_assert (desc->mClassID == eGameObjectClass_Decoration);
138+ if (desc->mClassID == eGameObjectClass_Decoration)
139+ {
140+ GameObjectID objectID = GenerateUniqueID ();
141+
142+ instance = mDecorationsPool .create (objectID, desc);
143+ debug_assert (instance);
144+
145+ mAllObjectsList .push_back (instance);
146+ // init
147+ instance->Spawn (position, heading);
148+ }
149+ return instance;
150+ }
151+
132152Vehicle* GameObjectsManager::GetVehicleByID (GameObjectID objectID) const
133153{
134154 for (GameObject* currentObject: mAllObjectsList )
@@ -231,8 +251,15 @@ void GameObjectsManager::DestroyGameObject(GameObject* object)
231251 mProjectilesPool .destroy (projectile);
232252 }
233253 break ;
234- case eGameObjectClass_Powerup:
254+
235255 case eGameObjectClass_Decoration:
256+ {
257+ Decoration* decoration = static_cast <Decoration*>(object);
258+ mDecorationsPool .destroy (decoration);
259+ }
260+ break ;
261+
262+ case eGameObjectClass_Powerup:
236263 case eGameObjectClass_Obstacle:
237264 default :
238265 {
@@ -276,14 +303,14 @@ bool GameObjectsManager::CreateStartupObjects()
276303 {
277304 int mapLevel = (int ) Convert::PixelsToMapUnits (currObject.mZ );
278305 mapLevel = INVERT_MAP_LAYER (mapLevel);
279- glm::vec3 carPosition
306+ glm::vec3 start_position
280307 {
281308 Convert::PixelsToMeters (currObject.mX ),
282309 Convert::MapUnitsToMeters (mapLevel * 1 .0f ),
283310 Convert::PixelsToMeters (currObject.mY )
284311 };
285312
286- cxx::angle_t rotationDegrees = Convert::Fix16ToAngle (currObject.mRotation );
313+ cxx::angle_t start_rotation = Convert::Fix16ToAngle (currObject.mRotation );
287314
288315 // create startup cars
289316 if (currObject.IsCarObject ())
@@ -294,7 +321,7 @@ bool GameObjectsManager::CreateStartupObjects()
294321 debug_assert (false );
295322 continue ;
296323 }
297- Vehicle* startupCar = CreateCar (carPosition, rotationDegrees , carModel);
324+ Vehicle* startupCar = CreateCar (start_position, start_rotation , carModel);
298325 debug_assert (startupCar);
299326 continue ;
300327 }
@@ -306,9 +333,14 @@ bool GameObjectsManager::CreateStartupObjects()
306333 GameObjectStyle& objectType = styleData.mGameObjects [objectTypeIndex];
307334 switch (objectType.mClassID )
308335 {
336+ case eGameObjectClass_Decoration:
337+ {
338+ Decoration* startupDecoration = CreateDecoration (start_position, start_rotation, &objectType);
339+ debug_assert (startupDecoration);
340+ }
341+ break ;
309342 case eGameObjectClass_Projectile: break ;
310343 case eGameObjectClass_Powerup: break ;
311- case eGameObjectClass_Decoration: break ;
312344 case eGameObjectClass_Obstacle: break ;
313345 default :
314346 debug_assert (false );
0 commit comments