From 2ff28e1127a82610d9402c90f7a2d1c1c7a19b6f Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Tue, 13 Feb 2018 20:03:16 +0000 Subject: [entity] Fixing builds too --- yage/entity/engine.cpp | 14 ------------ yage/entity/engine.h | 6 ------ yage/entity/space.h | 3 --- yage/entity/system.h | 52 +++++++++++++++++---------------------------- yage/entity/systemmanager.h | 15 +++++++++++++ 5 files changed, 35 insertions(+), 55 deletions(-) create mode 100644 yage/entity/systemmanager.h (limited to 'yage') diff --git a/yage/entity/engine.cpp b/yage/entity/engine.cpp index cf6f73b7..919cff7c 100644 --- a/yage/entity/engine.cpp +++ b/yage/entity/engine.cpp @@ -14,10 +14,6 @@ namespace yage void Engine::init() { window_.create("Game Engine", 800, 640); - - for (auto &system : systems_) { - system->init(); - } } void Engine::mainLoop() @@ -33,16 +29,6 @@ void Engine::mainLoop() void Engine::update() { - const double dt = 1.0 / 60.0; - - for (auto &system : systems_) { - system->update(dt); - } -} - -void Engine::addSystem(System *system) -{ - systems_.push_back(system); } Engine &Engine::instance() diff --git a/yage/entity/engine.h b/yage/entity/engine.h index 147769e5..6e1bf49a 100644 --- a/yage/entity/engine.h +++ b/yage/entity/engine.h @@ -31,17 +31,11 @@ public: /// Updates the systems. void update(); - /// Adds a system to the engine. - void addSystem(System *system); - /// Returns the instance of the engine, as there is only one instance of the /// engine. static Engine &instance(); private: - /// Vector of all the systems in the engine. - std::vector systems_; - /// Window Window window_; }; diff --git a/yage/entity/space.h b/yage/entity/space.h index e69df37a..96154ffc 100644 --- a/yage/entity/space.h +++ b/yage/entity/space.h @@ -16,8 +16,6 @@ namespace yage { -class System; - /** * Space that keeps track of all the entities, componenets and runs the systems * on the data to update them. There can be multiple instances of a space, which @@ -47,7 +45,6 @@ private: * component. These are specific to the Space, as other spaces might have * different Systems and not act on the same entities. */ - std::vector systems_; /** * Manages all the entities in the system, can create them for the current diff --git a/yage/entity/system.h b/yage/entity/system.h index 9100fa17..47d176c9 100644 --- a/yage/entity/system.h +++ b/yage/entity/system.h @@ -9,48 +9,36 @@ #ifndef YAGE_ENGINE_SYSTEM_H #define YAGE_ENGINE_SYSTEM_H +#include + +#include "../util/noncopyable.h" + namespace yage { +class BaseSystem : public yage::NonCopyable +{ +public: + typedef std::size_t Identifier; + + virtual void update() = 0; + +protected: + Identifier id_; +}; + /** * System interface for the different systems in the engine. */ -class System +template +class System : public BaseSystem { public: - /** - * Virtual destructor to destroy all the objects that implement this - * properly. - */ - virtual ~System() = 0; - - /** - * Initializes the system. Good practice to have this function instead - * using the constructor. - */ - virtual void init() = 0; - - /** - * Updates the system at each interval using the time step. - * - * @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; }; -/** - * Implement the default destructor, but leaving it as purely virtual in the - * definition of the abstract class. This is so that the classes that implement - * the abstract class have to implement a desctructor, but at the same time, - * that there is no undefined behavious when the stack unwinds to the system and - * calls the system destructor. - */ -inline System::~System() {} +class SystemManager : public yage::NonCopyable { + +}; } // namespace yage diff --git a/yage/entity/systemmanager.h b/yage/entity/systemmanager.h new file mode 100644 index 00000000..5351e4bb --- /dev/null +++ b/yage/entity/systemmanager.h @@ -0,0 +1,15 @@ +#ifndef YAGE_ENTITY_SYSTEMMANAGER_H +#define YAGE_ENTITY_SYSTEMMANAGER_H + +#include + +namespace yage { + +class SystemManager { +private: + std::unordered_map +}; + +} // namespace yage + +#endif -- cgit