aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-05-20 21:28:00 +0100
committerYann Herklotz <ymherklotz@gmail.com>2018-05-20 21:28:00 +0100
commitd849aae7a61c4c945230c6af051e8c9d5a071380 (patch)
treeaad0b48821f11dd49fe6a2be67d016f9e5f5443c
parent97448eb557d23138e6a460f496d981ced56b59c9 (diff)
downloadYAGE-d849aae7a61c4c945230c6af051e8c9d5a071380.tar.gz
YAGE-d849aae7a61c4c945230c6af051e8c9d5a071380.zip
Component pool now in entities
-rw-r--r--.dir-locals.el2
-rw-r--r--examples/simple/main.cpp2
-rw-r--r--yage/entity/componentmanager.h17
-rw-r--r--yage/entity/entity.cpp (renamed from yage/entity/entitymanager.cpp)6
-rw-r--r--yage/entity/entity.h (renamed from yage/entity/entitymanager.h)25
-rw-r--r--yage/entity/space.h6
6 files changed, 36 insertions, 22 deletions
diff --git a/.dir-locals.el b/.dir-locals.el
index f1672c13..40e6adb0 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -1,3 +1,3 @@
((nil . ((projectile-project-compilation-cmd . "mkdir -p build && cd build && cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. && ninja -j4")
- (projectile-project-test-cmd . "cd build/tests && ctest")
+ (projectile-project-test-cmd . "cd build/tests && ctest -j4 --schedule-random")
(projectile-project-run-cmd . "./build/bin/simplegame"))))
diff --git a/examples/simple/main.cpp b/examples/simple/main.cpp
index 0869f9b1..c25c41df 100644
--- a/examples/simple/main.cpp
+++ b/examples/simple/main.cpp
@@ -1,5 +1,7 @@
#include <iostream>
+#include <yage/yage.h>
+
int main()
{
std::cout << "Hello world";
diff --git a/yage/entity/componentmanager.h b/yage/entity/componentmanager.h
deleted file mode 100644
index fa1096e7..00000000
--- a/yage/entity/componentmanager.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#pragma once
-
-#include <map>
-
-#include "entitymanager.h"
-
-namespace yage
-{
-
-template <typename CompT>
-class ComponentMapper
-{
-private:
- std::map<Entity, CompT> map_;
-};
-
-} // namespace yage
diff --git a/yage/entity/entitymanager.cpp b/yage/entity/entity.cpp
index c37bc620..c7e8fd50 100644
--- a/yage/entity/entitymanager.cpp
+++ b/yage/entity/entity.cpp
@@ -1,18 +1,20 @@
/** ---------------------------------------------------------------------------
- * @file: entitymanager.cpp
+ * @file: entity.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-#include "entitymanager.h"
+#include "entity.h"
#include <algorithm>
namespace yage
{
+BaseComponent::Group BaseComponent::group_id_counter_ = 0;
+
EntityManager::EntityManager(Space *space) : space_(space) {}
EntityManager::EntityManager(Space *space, std::size_t n) : space_(space)
diff --git a/yage/entity/entitymanager.h b/yage/entity/entity.h
index 97f7c6f9..26d391b5 100644
--- a/yage/entity/entitymanager.h
+++ b/yage/entity/entity.h
@@ -1,5 +1,5 @@
/** ---------------------------------------------------------------------------
- * @file: entitymanager.h
+ * @file: entity.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -9,11 +9,13 @@
#pragma once
#include <vector>
+#include <memory>
namespace yage
{
class Space;
+class ComponentPool;
typedef unsigned int Entity;
@@ -72,6 +74,27 @@ private:
* The entities in the current space.
*/
std::vector<Entity> entities_;
+
+ std::vector<std::unique_ptr<ComponentPool>> components;
+};
+
+class BaseComponent {
+public:
+ typedef unsigned Group;
+
+protected:
+ static Group group_id_counter_;
+};
+
+template <typename Derived>
+class Component : public BaseComponent {
+private:
+ BaseComponent::Group group();
+};
+
+class ComponentPool {
+private:
+ std::vector<BaseComponent *> components_;
};
} // namespace yage
diff --git a/yage/entity/space.h b/yage/entity/space.h
index dff2d2ce..ed867534 100644
--- a/yage/entity/space.h
+++ b/yage/entity/space.h
@@ -11,9 +11,13 @@
#include <vector>
#include <memory>
-#include "entitymanager.h"
+#include "entity.h"
#include "system.h"
+struct Movement {
+
+};
+
namespace yage
{