aboutsummaryrefslogtreecommitdiffstats
path: root/include/engine.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/engine.hpp')
-rw-r--r--include/engine.hpp43
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.
*/