aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/component_test.cpp13
-rw-r--r--yage/entity/component.cpp6
-rw-r--r--yage/entity/component.h17
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/component_test.cpp b/tests/component_test.cpp
new file mode 100644
index 00000000..db42c287
--- /dev/null
+++ b/tests/component_test.cpp
@@ -0,0 +1,13 @@
+#include <yage/entity/entity.h>
+
+struct Position {
+ double x;
+ double y;
+
+ Position(double x_i, double y_i) : x(x_i), y(y_i) {}
+};
+
+int main() {
+ EntityManager em();
+ Entity player = em.createEntity();
+}
diff --git a/yage/entity/component.cpp b/yage/entity/component.cpp
new file mode 100644
index 00000000..83fe4424
--- /dev/null
+++ b/yage/entity/component.cpp
@@ -0,0 +1,6 @@
+#include "component.h"
+
+GroupId BaseComponent::getGroup() {
+ static GroupId group_id = group_id_counter_++;
+ return group_id;
+}
diff --git a/yage/entity/component.h b/yage/entity/component.h
new file mode 100644
index 00000000..84eb8b54
--- /dev/null
+++ b/yage/entity/component.h
@@ -0,0 +1,17 @@
+typedef unsigned int GroupId;
+
+class BaseComponent
+{
+protected:
+ GroupId getGroup();
+
+private:
+ friend class EntityManager;
+
+ static GroupId group_id_counter_;
+};
+
+template <typename T>
+class Component : public BaseComponent
+{
+};