diff options
Diffstat (limited to 'mwe/ecs-homemade/inc')
-rw-r--r-- | mwe/ecs-homemade/inc/ComponentManager.h | 2 | ||||
-rw-r--r-- | mwe/ecs-homemade/inc/ComponentManager.hpp | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/mwe/ecs-homemade/inc/ComponentManager.h b/mwe/ecs-homemade/inc/ComponentManager.h index 893aa56..1a58b01 100644 --- a/mwe/ecs-homemade/inc/ComponentManager.h +++ b/mwe/ecs-homemade/inc/ComponentManager.h @@ -29,7 +29,7 @@ public: template <typename T> std::vector<std::reference_wrapper<T>> GetComponentsByID(std::uint32_t id) const; //Get a vector<> of all components at specific type and id template <typename T> - std::vector<std::pair<std::reference_wrapper<T>, std::uint32_t>> GetComponentsByType() const; //Get a vector<> of all components of a specific type + std::vector<std::reference_wrapper<T>> GetComponentsByType() const; //Get a vector<> of all components of a specific type private: static ComponentManager mInstance; //Singleton diff --git a/mwe/ecs-homemade/inc/ComponentManager.hpp b/mwe/ecs-homemade/inc/ComponentManager.hpp index 53dfddd..720ee79 100644 --- a/mwe/ecs-homemade/inc/ComponentManager.hpp +++ b/mwe/ecs-homemade/inc/ComponentManager.hpp @@ -61,11 +61,11 @@ std::vector<std::reference_wrapper<T>> ComponentManager::GetComponentsByID(std:: } template <typename T> -std::vector<std::pair<std::reference_wrapper<T>, std::uint32_t>> ComponentManager::GetComponentsByType() const { +std::vector<std::reference_wrapper<T>> ComponentManager::GetComponentsByType() const { std::type_index type = typeid(T); //Determine the type of T (this is used as the key of the unordered_map<>) - std::vector<std::pair<std::reference_wrapper<T>, std::uint32_t>> componentVector; //Create an empty vector<> - std::uint32_t id = 0; //Set the id to 0 (the id will also be stored in the returned vector<>) + std::vector<std::reference_wrapper<T>> componentVector; //Create an empty vector<> + //std::uint32_t id = 0; //Set the id to 0 (the id will also be stored in the returned vector<>) if (mComponents.find(type) != mComponents.end()) { //Find the type (in the unordered_map<>) @@ -76,11 +76,11 @@ std::vector<std::pair<std::reference_wrapper<T>, std::uint32_t>> ComponentManage T* castedComponent = static_cast<T*>(componentPtr.get()); //Cast the unique_ptr to a raw pointer if (castedComponent) { //Ensure that the cast was successful - componentVector.emplace_back(std::ref(*castedComponent), id); //Pair the dereferenced raw pointer and the id and add it to the vector<> + componentVector.emplace_back(std::ref(*castedComponent)); //Pair the dereferenced raw pointer and the id and add it to the vector<> } } - ++id; //Increase the id (the id will also be stored in the returned vector<>) + //++id; //Increase the id (the id will also be stored in the returned vector<>) } } |