Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn

This commit is contained in:
ViktorLjung
2014-03-13 21:42:39 +01:00
2 changed files with 28 additions and 14 deletions
+10
View File
@@ -36,6 +36,8 @@ void World::Update(double dt)
system->Update(dt);
RecursiveUpdate(system, dt, 0);
}
ProcessEntityRemovals();
}
//std::vector<EntityID> GetEntityChildren(EntityID entity);
@@ -60,6 +62,12 @@ bool World::ValidEntity(EntityID entity)
void World::RemoveEntity(EntityID entity)
{
m_EntitiesToRemove.push_back(entity);
}
void World::ProcessEntityRemovals()
{
for (auto entity : m_EntitiesToRemove) {
m_EntityParents.erase(entity);
// Remove components
for (auto pair : m_EntityComponents[entity]) {
@@ -76,6 +84,8 @@ void World::RemoveEntity(EntityID entity)
RecycleEntityID(entity);
}
m_EntitiesToRemove.clear();
}
EntityID World::CreateEntity(EntityID parent /*= 0*/)
{
+4
View File
@@ -85,9 +85,13 @@ protected:
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;
std::list<EntityID> m_EntitiesToRemove;
void ProcessEntityRemovals();
EntityID GenerateEntityID();
void RecycleEntityID(EntityID id);
};
template <class T>