aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/ComponentManager.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-06 13:22:10 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-06 13:22:10 +0200
commit7c9d3452c99fcb89ea6df55755e90f741b23cf10 (patch)
tree93fab445cd4c0ebb392c2f4def2a0bd32d2709d2 /src/crepe/ComponentManager.cpp
parent02d658a7ed92bacfdaed587102f0d2e5f6c5dc01 (diff)
copy homemade ECS to crepe + correct code style
Diffstat (limited to 'src/crepe/ComponentManager.cpp')
-rw-r--r--src/crepe/ComponentManager.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/crepe/ComponentManager.cpp b/src/crepe/ComponentManager.cpp
new file mode 100644
index 0000000..b7a1bea
--- /dev/null
+++ b/src/crepe/ComponentManager.cpp
@@ -0,0 +1,25 @@
+#include "ComponentManager.h"
+
+using namespace crepe;
+
+ComponentManager & ComponentManager::get_instance() {
+ static ComponentManager instance;
+ return instance;
+}
+
+void ComponentManager::DeleteAllComponentsOfId(std::uint32_t id) {
+ // Loop through all the types (in the unordered_map<>)
+ for (auto & [type, componentArray] : components) {
+ // Make sure that the id (that we are looking for) is within the boundaries of the vector<>
+ if (id < componentArray.size()) {
+ // Clear the components at this specific id
+ componentArray[id].clear();
+ }
+ }
+}
+
+void ComponentManager::DeleteAllComponents() {
+ // Clear the whole unordered_map<>
+ components.clear();
+}
+