diff options
author | Andy Belle-Isle <drumsetmonkey@gmail.com> | 2019-09-07 01:24:15 -0400 |
---|---|---|
committer | Andy Belle-Isle <drumsetmonkey@gmail.com> | 2019-09-07 01:24:15 -0400 |
commit | 2417abe35038e903bf63d996ae6252173aa878a2 (patch) | |
tree | 38722a150bf08803d87157df37605127332d1b79 | |
parent | c9f8936fcb1afb07ead095f5c560473dc97eb3f6 (diff) |
Removed EntityX pointers from script system and replaced with references
-rw-r--r-- | src/engine.cpp | 2 | ||||
-rw-r--r-- | src/script.cpp | 9 | ||||
-rw-r--r-- | src/script.hpp | 6 |
3 files changed, 7 insertions, 10 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index d8e8bab..66739ff 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -45,7 +45,7 @@ int Engine::init(void) systems.add<InputSystem>(); systems.add<PlayerSystem>(entities); systems.add<RenderSystem>(); - systems.add<ScriptSystem>(); + systems.add<ScriptSystem>(entities); systems.add<PhysicsSystem>(); systems.configure(); diff --git a/src/script.cpp b/src/script.cpp index e1dea6a..a6f0968 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -24,12 +24,9 @@ * SYSTEM SPECIFIC * *********************/ -void ScriptSystem::configure(entityx::EntityManager& entities, - entityx::EventManager& events) +void ScriptSystem::configure([[maybe_unused]] entityx::EntityManager& entities, + [[maybe_unused]] entityx::EventManager& events) { - this->manager = &entities; - this->events = &events; - events.subscribe<EntitySpawnEvent>(*this); // Init after systems.configure() in engine.cpp @@ -137,7 +134,7 @@ sol::table ScriptSystem::spawn(sol::object param) if (param.get_type() == sol::type::table) { sol::table tab = param; // Cast the generic parameter to a table - entityx::Entity e = manager->create(); // Create a new entity + entityx::Entity e = manager.create(); // Create a new entity auto d = e.assign<Scripted>().get(); // Since this entity was created // via Lua, assign the Scripted // component. diff --git a/src/script.hpp b/src/script.hpp index 84c698c..d4e2234 100644 --- a/src/script.hpp +++ b/src/script.hpp @@ -46,11 +46,11 @@ private: */ sol::state lua; - entityx::EventManager* events; - entityx::EntityManager* manager; + entityx::EntityManager& manager; public: - ScriptSystem(void) {} + ScriptSystem(entityx::EntityManager& _manager): + manager(_manager) {} ~ScriptSystem(void) {} |