diff options
author | Max-001 <80035972+Max-001@users.noreply.github.com> | 2024-10-02 12:35:01 +0200 |
---|---|---|
committer | Max-001 <80035972+Max-001@users.noreply.github.com> | 2024-10-02 12:35:01 +0200 |
commit | e409986d9a21ca96ee0b491826eb0008ff6ab8e0 (patch) | |
tree | 89f04830a0e3727f53e15b4ebff70a95add40c30 /mwe/ecs-homemade/inc/ComponentManager.h | |
parent | aedbb8b82f13d8b390419e59cea098ea73295df5 (diff) |
Changed componentsManager to allow mutliple componts of the same type for one entity (id)
Diffstat (limited to 'mwe/ecs-homemade/inc/ComponentManager.h')
-rw-r--r-- | mwe/ecs-homemade/inc/ComponentManager.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/mwe/ecs-homemade/inc/ComponentManager.h b/mwe/ecs-homemade/inc/ComponentManager.h index cfc5f20..5b0629f 100644 --- a/mwe/ecs-homemade/inc/ComponentManager.h +++ b/mwe/ecs-homemade/inc/ComponentManager.h @@ -17,21 +17,21 @@ public: ComponentManager& operator=(const ComponentManager&) = delete; ComponentManager& operator=(ComponentManager&&) = delete; + template <typename T, typename... Args> + void AddComponent(std::uint32_t id, Args&&... args); template <typename T> - void AddComponent(T* component, std::uint32_t id); - template <typename T> - T* GetComponent(std::uint32_t id); - template <typename T> + std::vector<std::reference_wrapper<T>> GetComponentsOfID(std::uint32_t id); + /*template <typename T> std::vector<std::uint32_t> GetAllComponentIDs(); template <typename T> - std::vector<T*> GetAllComponentPointer(); + std::vector<T*> GetAllComponentPointer();*/ private: static ComponentManager mInstance; ComponentManager(); - std::unordered_map<std::type_index, std::vector<Component*>> mComponents; //TODO: Make this not only work with Component* OR add extra checks at templated methodes!!! + std::unordered_map<std::type_index, std::vector<std::vector<std::unique_ptr<Component>>>> mComponents; }; #include "ComponentManager.hpp" |