Changed type of components container to make deleting more efficient

This commit is contained in:
2014-03-13 02:39:08 +01:00
parent e20516f993
commit ded88eaadd
3 changed files with 2 additions and 3 deletions
-1
View File
@@ -69,7 +69,6 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
float TurnSpeed = 2.0f;
glm::vec3 Euler = glm::eulerAngles(transform->Orientation);
LOG_DEBUG("Euler: %f", Euler.z);
if(input->KeyState[GLFW_KEY_LEFT]) {
transform->Position -= Ship_Right * (float)dt * speed;
+1 -1
View File
@@ -65,7 +65,7 @@ void World::RemoveEntity(EntityID entity)
for (auto pair : m_EntityComponents[entity]) {
auto type = pair.first;
auto component = pair.second;
m_ComponentsOfType[type].erase(std::remove(m_ComponentsOfType[type].begin(), m_ComponentsOfType[type].end(), component));
m_ComponentsOfType[type].remove(component);
}
RecycleEntityID(entity);
}
+1 -1
View File
@@ -81,7 +81,7 @@ protected:
std::unordered_map<EntityID, std::unordered_map<std::string, boost::any>> m_EntityProperties;
std::unordered_map<std::string, std::vector<std::shared_ptr<Component>>> m_ComponentsOfType;
std::unordered_map<std::string, std::list<std::shared_ptr<Component>>> m_ComponentsOfType;
std::unordered_map<EntityID, std::map<std::string, std::shared_ptr<Component>>> m_EntityComponents;
EntityID GenerateEntityID();