diff --git a/Aeon/Entity/ComponentController.hpp b/Aeon/Entity/ComponentController.hpp index aee7e43..1587e01 100644 --- a/Aeon/Entity/ComponentController.hpp +++ b/Aeon/Entity/ComponentController.hpp @@ -3,45 +3,61 @@ #include +struct Entity; namespace EC { -struct IComponentArr +// I wish i diddn't have to do it like this +// someone fix this ahaha +struct IComponentContainer { - + virtual ~IComponentContainer() = default; + virtual void Create(const Entity&) = 0; + virtual void Destroy(const Entity&) = 0; }; template -struct ComponentArr : public IComponentArr +struct ComponentContainer : public IComponentContainer { + ComponentContainer() + { + + } + + + void Destroy(const Entity&) override + { + + } + +private: + - void Destroy(); }; class ComponentController { public: - ComponentController() + inline ComponentController() { } - ~ComponentController() + inline ~ComponentController() { } template - void Register() + inline void Register() { - const char* name = typeid(TComponent).name(); - std::cout << name << std::endl; + std::string componentTypeName = static_cast(typeid(TComponent).name()); + std::cout << componentTypeName << std::endl; } private: - std::map - + std::map mComponentContainers; }; diff --git a/Aeon/Entity/Entity.hpp b/Aeon/Entity/Entity.hpp index 00707ae..2d6b017 100644 --- a/Aeon/Entity/Entity.hpp +++ b/Aeon/Entity/Entity.hpp @@ -6,20 +6,7 @@ namespace EC { -struct Entity -{ - uint32_t id; - - inline bool operator==( const Entity& rhs ) - { - return rhs.id == id; - } - - inline bool operator!=( const Entity& rhs ) - { - return rhs.id != id; - } -}; +using Entity = uint32_t; } diff --git a/Aeon/Entity/EntityController.cpp b/Aeon/Entity/EntityController.cpp new file mode 100644 index 0000000..54bc71f --- /dev/null +++ b/Aeon/Entity/EntityController.cpp @@ -0,0 +1,39 @@ +#include "EntityController.hpp" + +using namespace EC; + + +EntityRegistry::EntityRegistry() +{ + +} + +EntityRegistry::~EntityRegistry() +{ + +} + +Entity EntityRegistry::Create() +{ + mEntityCeiling++; + uint32_t entityId = mEntityCeiling; + + Entity entity( { entityId } ); + mEntities.push( entity ); + return entity; +} + +Entity EntityRegistry::Copy( const Entity entity ) +{ + // look up everything, create a new entity and populate + // with the components in the og entity + + return Entity( { 0 } ); +} + +Entity EntityRegistry::Destroy( Entity entity ) +{ + auto id = entity.id; + mEntities = std::move(n.back()); // move last element to removal location + mEntities.pop_back(); +} diff --git a/Aeon/Entity/EntityController.hpp b/Aeon/Entity/EntityController.hpp index 94005dc..05b5f35 100644 --- a/Aeon/Entity/EntityController.hpp +++ b/Aeon/Entity/EntityController.hpp @@ -13,38 +13,32 @@ namespace EC class EntityRegistry { public: - EntityRegistry() - { + EntityRegistry(); + ~EntityRegistry(); - } - ~EntityRegistry() - { - - } - - Entity& Create(); - Entity& Copy(const Entity& entity); - Entity& Destroy(Entity& entity); - bool Valid(const Entity& entity); + Entity Create() + Entity Copy( const Entity entity ); + void Destroy( Entity entity ); + bool Valid(const Entity entity); // add, replace components template - TComponent& Add(const Entity& entity); + TComponent& Add(const Entity entity); template - TComponent& Replace(const Entity& entity); + TComponent& Replace(const Entity entity); // replace in-place template - TComponent& Patch(const Entity& entity); + TComponent& Patch(const Entity entity); // Get component from entity based on T template - TComponent& Get(const Entity& entity); + TComponent& Get(const Entity entity); // Get std::optional from entity based on T template - std::optional Opt(const Entity& entity); + std::optional Opt(const Entity entity); // TODO: Sort by component properties, for example list of // entities with the renderable components, sorted by Y pos @@ -53,7 +47,11 @@ public: // std::vector Sort(std::function<; private: - // std::map, std::vector> mEntities }; diff --git a/Aeon/Includes.hpp b/Aeon/Includes.hpp index 682000c..a7c746c 100644 --- a/Aeon/Includes.hpp +++ b/Aeon/Includes.hpp @@ -21,5 +21,7 @@ extern "C" { #include #include #include +#include +#include #endif diff --git a/Game/ExampleGame.cpp b/Game/ExampleGame.cpp index 89ac89c..2ded34c 100644 --- a/Game/ExampleGame.cpp +++ b/Game/ExampleGame.cpp @@ -106,17 +106,8 @@ public: }; - -struct GenericComponent -{ - int x,y; -}; - int main( int argc, char** argv ) { - EC::ComponentController cController; - - cController.Register(); ExampleGame game; return 0;