diff options
author | Andy <drumsetmonkey@gmail.com> | 2017-01-19 09:21:12 -0500 |
---|---|---|
committer | Andy <drumsetmonkey@gmail.com> | 2017-01-19 09:21:12 -0500 |
commit | 213d9ccfbb4752d4c62d6b7e6b3f9172cdf1bccc (patch) | |
tree | 7872c6f30c8adf048a7863a33d837299c7fb0771 /include/engine.hpp | |
parent | 19a32074595a4a2797eaeb978f8bd302f736f6a6 (diff) | |
parent | 8452b199d28bea53bf2c5e3b3d604064000fc73d (diff) |
Limb animation actually works
Diffstat (limited to 'include/engine.hpp')
-rw-r--r-- | include/engine.hpp | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/include/engine.hpp b/include/engine.hpp index 2b03696..417522d 100644 --- a/include/engine.hpp +++ b/include/engine.hpp @@ -40,13 +40,6 @@ public: void init(void); /** - * Updates all rendering systems. - * @param dt the delta time - */ - void render(entityx::TimeDelta dt); - void resetRender(entityx::TimeDelta dt); - - /** * Updates all logic systems. * @param dt the delta time */ @@ -70,6 +63,38 @@ public: } }; +#include <atomic> +#include <chrono> + +class LockableEntityManager : public entityx::EntityManager { +private: + std::atomic_bool locked; + +public: + LockableEntityManager(entityx::EventManager& ev) + : EntityManager(ev) { + locked.store(false); + } + + void lock(void) { + while (locked.load()) + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + + locked.store(true); + } + + void unlock(void) { + locked.store(false); + } + + bool try_lock(void) { + if (locked.load()) + return false; + + locked.store(true); + return true; + } +}; namespace game { /** @@ -80,8 +105,8 @@ namespace game { /** * Handles entity data. */ - extern entityx::EntityManager entities; - + extern LockableEntityManager entities; + /** * An instance of the main game engine. */ |