aboutsummaryrefslogtreecommitdiff
path: root/mwe/ecs-homemade/inc
diff options
context:
space:
mode:
authorMax-001 <80035972+Max-001@users.noreply.github.com>2024-10-02 16:37:47 +0200
committerMax-001 <80035972+Max-001@users.noreply.github.com>2024-10-02 16:37:47 +0200
commit0b6a5731401348ab5931a80e07e134ae460d9955 (patch)
tree72a6542eab7a2275831e812b8e55306d09033314 /mwe/ecs-homemade/inc
parentb242f28862ac8e9c1137c3f8e3640011a1ddddfa (diff)
Added DeleteComponentsById<> method
Diffstat (limited to 'mwe/ecs-homemade/inc')
-rw-r--r--mwe/ecs-homemade/inc/ComponentManager.hpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/mwe/ecs-homemade/inc/ComponentManager.hpp b/mwe/ecs-homemade/inc/ComponentManager.hpp
index e6523ca..75b2ab1 100644
--- a/mwe/ecs-homemade/inc/ComponentManager.hpp
+++ b/mwe/ecs-homemade/inc/ComponentManager.hpp
@@ -18,7 +18,13 @@ template <typename T>
void ComponentManager::DeleteComponentsById(std::uint32_t id) {
std::type_index type = typeid(T); //Determine the type of T (this is used as the key of the unordered_map<>)
-
+ if (mComponents.find(type) != mComponents.end()) { //Find the type (in the unordered_map<>)
+ std::vector<std::vector<std::unique_ptr<Component>>>& componentArray = mComponents[type]; //Get the correct vector<>
+
+ if (id < componentArray.size()) { //Make sure that the id (that we are looking for) is within the boundaries of the vector<>
+ componentArray[id].clear(); //Clear the whole vector<> of this specific type and id
+ }
+ }
}
template <typename T>