Browse Source

Lesson 9.4

Godzil 3 years ago
parent
commit
0e866b3176
2 changed files with 55 additions and 1 deletions
  1. 29 0
      source/ECS.cpp
  2. 26 1
      source/include/ECS.h

+ 29 - 0
source/ECS.cpp

@@ -9,3 +9,32 @@
 
 #include <ECS.h>
 
+/* Entity */
+
+/* TODO: this should be moved to the header file for optimisation purposes */
+uint32_t Entity::getId() const
+{
+    return this->id;
+}
+
+
+/* System */
+void System::addEntity(Entity entity)
+{
+
+}
+
+void System::removeEntity(Entity entity)
+{
+
+}
+
+std::vector<Entity> System::getEntities() const
+{
+
+}
+
+Signature& System::getComponentSignature() const
+{
+
+}

+ 26 - 1
source/include/ECS.h

@@ -10,6 +10,15 @@
 #ifndef GAMEENGINE_ECS_H
 #define GAMEENGINE_ECS_H
 
+#include <stdint.h>
+
+#include <bitset>
+#include <vector>
+
+const uint32_t MAX_COMPONENTS = 32;
+
+typedef std::bitset<MAX_COMPONENTS> Signature;
+
 class Component
 {
 
@@ -17,12 +26,28 @@ class Component
 
 class Entity
 {
+private:
+    uint32_t id;
 
+public:
+    Entity(uint32_t id): id(id) {};
+    uint32_t getId() const;
 };
 
 class System
 {
-
+private:
+    Signature componentSignature;
+    std::vector<Entity> entities;
+
+public:
+    System() = default;
+    ~System() = default;
+
+  void addEntity(Entity entity);
+  void removeEntity(Entity entity);
+  std::vector<Entity> getEntities() const;
+  Signature& getComponentSignature() const;
 };
 
 class Registry