diff options
author | Max-001 <80035972+Max-001@users.noreply.github.com> | 2024-10-02 16:29:17 +0200 |
---|---|---|
committer | Max-001 <80035972+Max-001@users.noreply.github.com> | 2024-10-02 16:29:17 +0200 |
commit | b242f28862ac8e9c1137c3f8e3640011a1ddddfa (patch) | |
tree | a419d8aa36a6675f791f7958d04e5cf3ab312229 /mwe/ecs-homemade/src | |
parent | 3e99a6fe36e63a1e14ba62f2a6e5a3827484e4e6 (diff) |
DeleteComponents<> method created
Diffstat (limited to 'mwe/ecs-homemade/src')
-rw-r--r-- | mwe/ecs-homemade/src/ComponentManager.cpp | 2 | ||||
-rw-r--r-- | mwe/ecs-homemade/src/main.cpp | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/mwe/ecs-homemade/src/ComponentManager.cpp b/mwe/ecs-homemade/src/ComponentManager.cpp index cca84bc..def50be 100644 --- a/mwe/ecs-homemade/src/ComponentManager.cpp +++ b/mwe/ecs-homemade/src/ComponentManager.cpp @@ -13,5 +13,5 @@ void ComponentManager::DeleteAllComponentsOfId(std::uint32_t id) { } void ComponentManager::DeleteAllComponents() { - mComponents.clear(); + mComponents.clear(); //Clear the whole unordered_map<> } diff --git a/mwe/ecs-homemade/src/main.cpp b/mwe/ecs-homemade/src/main.cpp index df229a2..e1ca9e9 100644 --- a/mwe/ecs-homemade/src/main.cpp +++ b/mwe/ecs-homemade/src/main.cpp @@ -69,6 +69,9 @@ int main() { } std::cout << std::endl; + ComponentManager::GetInstance().DeleteComponents<Sprite>(); + gameObect5.AddComponent<Sprite>(); + std::cout << "Finding all rigidbodies of entity 3" << std::endl; std::vector<std::reference_wrapper<Rigidbody>> rigidbodyOfEntity3 = ComponentManager::GetInstance().GetComponentsByID<Rigidbody>(gameObect3.mId); for(Rigidbody& rigidbodyEntity3 : rigidbodyOfEntity3) { @@ -99,8 +102,6 @@ int main() { } std::cout << std::endl; - ComponentManager::GetInstance().DeleteAllComponents(); - std::cout << "Finding all rigidbodies of all entities for the second time (after changing mMass to -1)" << std::endl; std::vector<std::pair<std::reference_wrapper<Rigidbody>, std::uint32_t>> rigidBodies2 = ComponentManager::GetInstance().GetComponentsByType<Rigidbody>(); for(auto& [rigidbody2, id2] : rigidBodies2) { |