Basic and working entity system with a really ugly test case
This commit is contained in:
+19
-16
@@ -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
|
||||
Reference in New Issue
Block a user