Merge remote-tracking branch 'origin/particles' into havok
Conflicts: src/Components/Vehicle.h
This commit is contained in:
+17
-11
@@ -37,6 +37,7 @@ public:
|
||||
std::shared_ptr<T> GetSystem(std::string systemType);
|
||||
|
||||
EntityID CreateEntity(EntityID parent = 0);
|
||||
EntityID CloneEntity(EntityID entity, EntityID parent = 0);
|
||||
|
||||
void RemoveEntity(EntityID entity);
|
||||
|
||||
@@ -44,6 +45,7 @@ public:
|
||||
|
||||
EntityID GetEntityParent(EntityID entity);
|
||||
EntityID GetEntityBaseParent(EntityID entity);
|
||||
std::list<EntityID> GetEntityChildren(EntityID entity);
|
||||
|
||||
template <class T>
|
||||
T GetProperty(EntityID entity, std::string property)
|
||||
@@ -95,13 +97,16 @@ protected:
|
||||
|
||||
EntityID m_LastEntityID;
|
||||
std::stack<EntityID> m_RecycledEntityIDs;
|
||||
// A bottom to top tree. A map of child entities to parent entities.
|
||||
std::unordered_map<EntityID, EntityID> m_EntityParents;
|
||||
std::unordered_map<EntityID, std::unordered_map<std::string, boost::any>> m_EntityProperties;
|
||||
|
||||
std::unordered_map<EntityID, EntityID> m_EntityParents; // child -> parent
|
||||
std::unordered_map<EntityID, std::list<EntityID>> m_EntityChildren; // parent -> child
|
||||
std::unordered_map<EntityID, std::unordered_map<std::string, boost::any>> m_EntityProperties;
|
||||
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;
|
||||
|
||||
// Internal: Add a component to an entity
|
||||
void AddComponent(EntityID entity, std::string componentType, std::shared_ptr<Component> component);
|
||||
|
||||
std::list<EntityID> m_EntitiesToRemove;
|
||||
void ProcessEntityRemovals();
|
||||
|
||||
@@ -133,14 +138,8 @@ std::shared_ptr<T> World::AddComponent(EntityID entity, std::string componentTyp
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
component->Entity = entity;
|
||||
m_ComponentsOfType[componentType].push_back(component);
|
||||
m_EntityComponents[entity][componentType] = component;
|
||||
for (auto pair : m_Systems)
|
||||
{
|
||||
auto system = pair.second;
|
||||
system->OnComponentCreated(componentType, component);
|
||||
}
|
||||
AddComponent(entity, componentType, component);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@@ -148,7 +147,14 @@ std::shared_ptr<T> World::AddComponent(EntityID entity, std::string componentTyp
|
||||
template <class T>
|
||||
T* World::GetComponent(EntityID entity, std::string componentType)
|
||||
{
|
||||
|
||||
/*auto it0 = m_EntityComponents.find(entity);
|
||||
|
||||
if (it0 == m_EntityComponents.end())
|
||||
return nullptr;*/
|
||||
|
||||
auto components = m_EntityComponents[entity];
|
||||
|
||||
auto it = components.find(componentType);
|
||||
if (it != components.end())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user