Advertisement
Guest User

EntityFactory

a guest
Sep 25th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. CEntity* PLevelEntityFactory::CreateEntity(ELevelEntityType entityType, const TVector2& position, const DLevelEntityProperties& properties)
  2. {
  3.     if (entityType == ELevelEntityType::ENTITY_BLADE)
  4.     {
  5.         CEntityBlade* blade = new CEntityBlade(position);
  6.  
  7.         if (PROPERTY_EXISTS(ELevelEntityPropertyType::AREA))
  8.         {
  9.             blade->SetBladeArea(properties.at(ELevelEntityPropertyType::AREA).ToVector2());
  10.         }
  11.  
  12.         return blade;
  13.     }
  14.     else if (entityType == ELevelEntityType::ENTITY_BLADE_SPINNER)
  15.     {
  16.         float bladeSpinnerRotation = 0.0f;
  17.  
  18.         if (PROPERTY_EXISTS(ELevelEntityPropertyType::BLADE_SPINNER_ROTATION))
  19.         {
  20.             bladeSpinnerRotation = properties.at(ELevelEntityPropertyType::BLADE_SPINNER_ROTATION).GetValue().ToFloat();
  21.         }
  22.  
  23.         return new CEntityBladeSpinner(position, bladeSpinnerRotation);
  24.     }
  25.     else if (entityType == ELevelEntityType::ENTITY_BOSS_PRISON)
  26.     {
  27.         return new CEntityBossPrison(position);
  28.     }
  29.  
  30.     return nullptr;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement