Godzil 3 anni fa
parent
commit
3414c9d291
1 ha cambiato i file con 3 aggiunte e 7 eliminazioni
  1. 3 7
      source/ECS.cpp

+ 3 - 7
source/ECS.cpp

@@ -26,14 +26,10 @@ void System::addEntity(Entity entity)
 
 void System::removeEntity(Entity entity)
 {
-    for(uint32_t i = 0; i < this->entities.size(); i++)
+    this->entities.erase(std::remove_if(this->entities.begin(), this->entities.end(), [&entity](Entity other)
     {
-        if (this->entities[i].getId() == entity.getId())
-        {
-            this->entities.erase(this->entities.begin() + i);
-            return;
-        }
-    }
+        return other.getId() == entity.getId();
+    }), this->entities.end());
 }
 
 std::vector<Entity> System::getEntities() const