]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
World system now has a pointer to the current world, and worlds created in Lua are...
authorAndy Belle-Isle <drumsetmonkey@gmail.com>
Wed, 11 Sep 2019 05:46:14 +0000 (01:46 -0400)
committerAndy Belle-Isle <drumsetmonkey@gmail.com>
Wed, 11 Sep 2019 05:46:14 +0000 (01:46 -0400)
src/script.cpp
src/world.cpp
src/world.hpp

index e3aca3ebb82d50381202c903c3f17e7dc9d617b6..f52391f57a123eb04227344189cf04e65dcc1906 100644 (file)
@@ -90,7 +90,7 @@ void ScriptSystem::scriptExport(void)
     std::function<sol::table(sol::table)> entitySpawn = 
         [this](sol::table t){ return spawn(t);};
 
-    std::function<unsigned int(sol::object)> worldRegister =
+    std::function<World* (sol::object)> worldRegister =
         [this](sol::object t){ return worldSystem.addWorld(t); };
 
     lua.new_usertype<Position>("Position",
index 8b71316be729102eced8c7445f54a3f4d7fe8438..63769a9e49206623c404ebd08f8e7755365ff8cd 100644 (file)
@@ -38,10 +38,12 @@ World::World(sol::object ref)
 *  WORLD SYSTEM  *
 ******************/
 
-unsigned int WorldSystem::addWorld(sol::object t)
+World* WorldSystem::addWorld(sol::object t)
 {
     worlds.push_back(World(t));
-    return worlds.size()-1;
+    if (currentWorld == nullptr)
+        currentWorld = &(worlds.back());
+    return &(worlds.back());
 }
 
 void WorldSystem::configure([[maybe_unused]]entityx::EntityManager& entities,
index 7c66e6bcf93b75a8e6a17e96c0b298ea3f17fa98..4ceca94be565cf2070c68cecee3d2286ba7f93a7 100644 (file)
@@ -52,13 +52,14 @@ class WorldSystem : public entityx::System<WorldSystem>
 {
 private:
     std::vector<World> worlds;
-    //World& currentWorld;
+    World* currentWorld;
 public:
-    WorldSystem(void) {}
+    WorldSystem(void):
+        currentWorld(nullptr) {}
 
     ~WorldSystem(void) {}
 
-    unsigned int addWorld(sol::object);
+    World* addWorld(sol::object);
 
     /**
      * Prepares the system for running.