Basic and working entity system with a really ugly test case

This commit is contained in:
sippeangelo
2015-12-03 15:07:35 +01:00
parent c7430a9338
commit d3d2e594fe
11 changed files with 286 additions and 135 deletions
+19 -16
View File
@@ -2,32 +2,35 @@
#define World_h__
#include "../Common.h"
#include "Entity.h"
#include "EntityWrapper.h"
#include "ObjectPool.h"
#include "ComponentPool.h"
class World
{
public:
World()
{
World() = default;
~World();
}
EntityID CreateEntity(EntityID parent = 0);
~World()
{
// foreach (m_ComponentPools...
}
void AllocateComponentPool(ComponentInfo& ci)
{
auto pool = new ComponentPool(ci);
m_ComponentPools[ci.Name] = pool;
}
void AddComponent(EntityID entity, std::string componentType);
// Register a component type and allocate space for it
void RegisterComponent(ComponentInfo& ci);
// Attach a component to an entity and fill it with default values
ComponentWrapper AttachComponent(EntityID entity, std::string componentType);
// Get a component of an entity
ComponentWrapper GetComponent(EntityID entity, std::string componentType);
// Get all components of the specified type
const ComponentPool& GetComponents(std::string componentType);
private:
EntityID m_CurrentEntityID = 0;
std::unordered_map<EntityID, EntityID> m_EntityParents;
std::unordered_multimap<EntityID, EntityID> m_EntityChildren;
std::unordered_map<std::string, ComponentPool*> m_ComponentPools;
EntityID generateEntityID();
};
#endif