diff options
-rw-r--r-- | .dir-locals.el | 2 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/engine/entities.json | 23 | ||||
-rw-r--r-- | tests/engine/test.cpp | 4 | ||||
-rw-r--r-- | yage/engine/component.h | 21 | ||||
-rw-r--r-- | yage/entity/engine.cpp (renamed from yage/engine/engine.cpp) | 0 | ||||
-rw-r--r-- | yage/entity/engine.h (renamed from yage/engine/engine.h) | 0 | ||||
-rw-r--r-- | yage/entity/entity.cpp (renamed from yage/engine/entity.cpp) | 0 | ||||
-rw-r--r-- | yage/entity/entity.h (renamed from yage/engine/entity.h) | 8 | ||||
-rw-r--r-- | yage/entity/entitymanager.cpp (renamed from yage/engine/entitymanager.cpp) | 0 | ||||
-rw-r--r-- | yage/entity/entitymanager.h (renamed from yage/engine/entitymanager.h) | 0 | ||||
-rw-r--r-- | yage/entity/space.cpp (renamed from yage/engine/space.cpp) | 0 | ||||
-rw-r--r-- | yage/entity/space.h (renamed from yage/engine/space.h) | 0 | ||||
-rw-r--r-- | yage/entity/system.h (renamed from yage/engine/system.h) | 5 | ||||
-rw-r--r-- | yage/util/noncopyable.h | 19 | ||||
-rw-r--r-- | yage/yage.h | 3 |
16 files changed, 57 insertions, 30 deletions
diff --git a/.dir-locals.el b/.dir-locals.el index 2e2c2aaa..f1672c13 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,3 +1,3 @@ -((nil . ((projectile-project-compilation-cmd . "mkdir -p build && cd build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. && make -j4") +((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-run-cmd . "./build/bin/simplegame")))) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea15bb0a..2633d4a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ file(GLOB YAGE_MATH_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} yage/math/*.cpp file(GLOB YAGE_PHYSICS_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} yage/physics/*.cpp) file(GLOB YAGE_UTIL_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} yage/util/*.cpp) file(GLOB YAGE_RENDER_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} yage/render/*.cpp) -file(GLOB YAGE_ENGINE_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} yage/engine/*.cpp) +file(GLOB YAGE_ENGINE_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} yage/entity/*.cpp) file(GLOB YAGE_CURRENT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} yage/*.cpp) set(YAGE_SOURCES diff --git a/tests/engine/entities.json b/tests/engine/entities.json new file mode 100644 index 00000000..25959311 --- /dev/null +++ b/tests/engine/entities.json @@ -0,0 +1,23 @@ +{ + "Entities": [ + { + "name": "Object1", + "mass": "Hello", + "position": [ + 0, + 0, + 0 + ], + "velocity": [ + 0, + 0, + 0 + ], + "acceleration": [ + 0, + 0, + 0 + ] + } + ] +} diff --git a/tests/engine/test.cpp b/tests/engine/test.cpp index 6026e40a..5095a974 100644 --- a/tests/engine/test.cpp +++ b/tests/engine/test.cpp @@ -1,4 +1,4 @@ -#include <yage/engine/space.h> +#include <yage/entity/space.h> #include <yage/yage.h> @@ -8,12 +8,12 @@ int main() auto entity = space.createEntity(); auto entity2 = space.createEntity(); auto entity3 = space.createEntity(); - auto entity4 = space.createEntity(); yLogInfo << "Entity 1: " << entity; yLogInfo << "Entity 3: " << entity3; yLogInfo << "Entity 2: " << entity2; yLogInfo << "Entity 4: " << entity4; + return 0; } diff --git a/yage/engine/component.h b/yage/engine/component.h deleted file mode 100644 index 9fd85d82..00000000 --- a/yage/engine/component.h +++ /dev/null @@ -1,21 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: component.h - * - * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#ifndef YAGE_ENGINE_COMPONENT_H -#define YAGE_ENGINE_COMPONENT_H - -class Component -{ -}; - -enum class ComponentEnum { - POSITION, - NAX_COMPONENTS, -}; - -#endif diff --git a/yage/engine/engine.cpp b/yage/entity/engine.cpp index cf6f73b7..cf6f73b7 100644 --- a/yage/engine/engine.cpp +++ b/yage/entity/engine.cpp diff --git a/yage/engine/engine.h b/yage/entity/engine.h index 147769e5..147769e5 100644 --- a/yage/engine/engine.h +++ b/yage/entity/engine.h diff --git a/yage/engine/entity.cpp b/yage/entity/entity.cpp index 4d9a4b0a..4d9a4b0a 100644 --- a/yage/engine/entity.cpp +++ b/yage/entity/entity.cpp diff --git a/yage/engine/entity.h b/yage/entity/entity.h index c31490e5..e6742893 100644 --- a/yage/engine/entity.h +++ b/yage/entity/entity.h @@ -14,6 +14,8 @@ namespace yage { +typedef unsigned EntityHandle; + class Space; /** @@ -32,20 +34,20 @@ public: * This handle refers to the position of he Entity in the list that is held * by the EntityManager, and therefore the id is enough to refer to it. */ - Entity(unsigned handle); + Entity(EntityHandle handle); /** * Handle getter, as the user will only interact with the id itself. The * handle is the unique identifier that the user can use to refer to the * entity. */ - unsigned getHandle() const; + EntityHandle getHandle() const; private: /** * Entity handle for the entity manager. */ - unsigned handle_; + EntityHandle handle_; }; } // namespace yage diff --git a/yage/engine/entitymanager.cpp b/yage/entity/entitymanager.cpp index 332ed9b8..332ed9b8 100644 --- a/yage/engine/entitymanager.cpp +++ b/yage/entity/entitymanager.cpp diff --git a/yage/engine/entitymanager.h b/yage/entity/entitymanager.h index da125d94..da125d94 100644 --- a/yage/engine/entitymanager.h +++ b/yage/entity/entitymanager.h diff --git a/yage/engine/space.cpp b/yage/entity/space.cpp index f3e343b5..f3e343b5 100644 --- a/yage/engine/space.cpp +++ b/yage/entity/space.cpp diff --git a/yage/engine/space.h b/yage/entity/space.h index e69df37a..e69df37a 100644 --- a/yage/engine/space.h +++ b/yage/entity/space.h diff --git a/yage/engine/system.h b/yage/entity/system.h index 32d6fc34..9100fa17 100644 --- a/yage/engine/system.h +++ b/yage/entity/system.h @@ -36,6 +36,11 @@ public: * @param dt The time difference between the previous frame and the current one. */ virtual void update(double dt) = 0; + + /** + * Destroy the system and the components that are contained in it. + */ + virtual void destroy() = 0; }; /** diff --git a/yage/util/noncopyable.h b/yage/util/noncopyable.h new file mode 100644 index 00000000..f1325ed1 --- /dev/null +++ b/yage/util/noncopyable.h @@ -0,0 +1,19 @@ +#ifndef YAGE_UTIL_NONCOPYABLE_H +#define YAGE_UTIL_NONCOPYABLE_H + +namespace yage +{ + +class NonCopyable +{ +protected: + NonCopyable() = default; + ~NonCopyable() = default; + + NonCopyable(const NonCopyable &) = delete; + NonCopyable &operator=(const NonCopyable &) = delete; +}; + +} // namespace yage + +#endif diff --git a/yage/yage.h b/yage/yage.h index ed21d245..d5b34603 100644 --- a/yage/yage.h +++ b/yage/yage.h @@ -50,8 +50,7 @@ * Engine that includes a Entity Component System to organize the data and make * it more flexible and efficient. */ -#include "engine/engine.h" - +#include "entity/engine.h" /** * Project namespace. * |