summary refs log tree commit diff stats
path: root/src/systems
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-05-13 11:00:02 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-05-17 15:39:39 -0400
commit046ee24a341468e9b3ea2983a731dbce18b52ac6 (patch)
tree554a645bbc9dac63433cf06e1a5168eb2551d02a /src/systems
parent5269e7c09a0b17c8c972c8ad996b04d42dbcd9cb (diff)
downloadtherapy-046ee24a341468e9b3ea2983a731dbce18b52ac6.tar.gz
therapy-046ee24a341468e9b3ea2983a731dbce18b52ac6.tar.bz2
therapy-046ee24a341468e9b3ea2983a731dbce18b52ac6.zip
Integrated RealizableComponent into RealizingSystem
Diffstat (limited to 'src/systems')
-rw-r--r--src/systems/mapping.cpp8
-rw-r--r--src/systems/playing.cpp26
-rw-r--r--src/systems/pondering.cpp8
-rw-r--r--src/systems/realizing.cpp105
-rw-r--r--src/systems/realizing.h66
-rw-r--r--src/systems/scripting.cpp45
-rw-r--r--src/systems/scripting.h2
7 files changed, 125 insertions, 135 deletions
diff --git a/src/systems/mapping.cpp b/src/systems/mapping.cpp index d78c8fe..1275e11 100644 --- a/src/systems/mapping.cpp +++ b/src/systems/mapping.cpp
@@ -1,6 +1,5 @@
1#include "mapping.h" 1#include "mapping.h"
2#include "components/mappable.h" 2#include "components/mappable.h"
3#include "components/realizable.h"
4#include "systems/realizing.h" 3#include "systems/realizing.h"
5#include "game.h" 4#include "game.h"
6#include "consts.h" 5#include "consts.h"
@@ -20,11 +19,8 @@ inline void addBoundary(
20 19
21void MappingSystem::render(Texture& texture) 20void MappingSystem::render(Texture& texture)
22{ 21{
23 auto& realizable = game_.getEntityManager(). 22 id_type map =
24 getComponent<RealizableComponent>( 23 game_.getSystemManager().getSystem<RealizingSystem>().getActiveMap();
25 game_.getSystemManager().getSystem<RealizingSystem>().getSingleton());
26
27 id_type map = realizable.activeMap;
28 24
29 auto& mappable = game_.getEntityManager(). 25 auto& mappable = game_.getEntityManager().
30 getComponent<MappableComponent>(map); 26 getComponent<MappableComponent>(map);
diff --git a/src/systems/playing.cpp b/src/systems/playing.cpp index dabc9a5..6652099 100644 --- a/src/systems/playing.cpp +++ b/src/systems/playing.cpp
@@ -5,7 +5,6 @@
5#include "components/playable.h" 5#include "components/playable.h"
6#include "components/controllable.h" 6#include "components/controllable.h"
7#include "components/orientable.h" 7#include "components/orientable.h"
8#include "components/realizable.h"
9#include "systems/mapping.h" 8#include "systems/mapping.h"
10#include "systems/pondering.h" 9#include "systems/pondering.h"
11#include "systems/orienting.h" 10#include "systems/orienting.h"
@@ -36,13 +35,10 @@ void PlayingSystem::initPlayer()
36 35
37 auto& realizing = game_.getSystemManager().getSystem<RealizingSystem>(); 36 auto& realizing = game_.getSystemManager().getSystem<RealizingSystem>();
38 37
39 auto& realizable = game_.getEntityManager().
40 getComponent<RealizableComponent>(realizing.getSingleton());
41
42 auto& transformable = game_.getEntityManager(). 38 auto& transformable = game_.getEntityManager().
43 emplaceComponent<TransformableComponent>(player); 39 emplaceComponent<TransformableComponent>(player);
44 40
45 transformable.pos = realizable.startingPos; 41 transformable.pos = realizing.getStartingPos();
46 transformable.size.w() = 10; 42 transformable.size.w() = 10;
47 transformable.size.h() = 12; 43 transformable.size.h() = 12;
48 44
@@ -56,13 +52,13 @@ void PlayingSystem::initPlayer()
56 auto& playable = game_.getEntityManager(). 52 auto& playable = game_.getEntityManager().
57 emplaceComponent<PlayableComponent>(player); 53 emplaceComponent<PlayableComponent>(player);
58 54
59 playable.mapId = realizable.activeMap; 55 playable.mapId = realizing.getActiveMap();
60 playable.checkpointMapId = realizable.startingMapId; 56 playable.checkpointMapId = realizing.getStartingMapId();
61 playable.checkpointPos = realizable.startingPos; 57 playable.checkpointPos = realizing.getStartingPos();
62 58
63 realizing.enterActiveMap(player); 59 realizing.enterActiveMap(player);
64 60
65 realizable.activePlayer = player; 61 realizing.setActivePlayer(player);
66} 62}
67 63
68void PlayingSystem::changeMap( 64void PlayingSystem::changeMap(
@@ -77,20 +73,16 @@ void PlayingSystem::changeMap(
77 getComponent<TransformableComponent>(player); 73 getComponent<TransformableComponent>(player);
78 74
79 auto& pondering = game_.getSystemManager().getSystem<PonderingSystem>(); 75 auto& pondering = game_.getSystemManager().getSystem<PonderingSystem>();
80
81 auto& realizing = game_.getSystemManager().getSystem<RealizingSystem>(); 76 auto& realizing = game_.getSystemManager().getSystem<RealizingSystem>();
82 77
83 auto& realizable = game_.getEntityManager(). 78 id_type newMapEntity = realizing.getEntityByMapId(mapId);
84 getComponent<RealizableComponent>(realizing.getSingleton());
85
86 id_type newMapEntity = realizable.entityByMapId[mapId];
87 79
88 if (playable.mapId != newMapEntity) 80 if (playable.mapId != newMapEntity)
89 { 81 {
90 if (playable.mapId == realizable.activeMap) 82 if (playable.mapId == realizing.getActiveMap())
91 { 83 {
92 realizing.leaveActiveMap(player); 84 realizing.leaveActiveMap(player);
93 } else if (newMapEntity == realizable.activeMap) 85 } else if (newMapEntity == realizing.getActiveMap())
94 { 86 {
95 realizing.enterActiveMap(player); 87 realizing.enterActiveMap(player);
96 } 88 }
@@ -102,7 +94,7 @@ void PlayingSystem::changeMap(
102 94
103 transformable.pos = warpPos; 95 transformable.pos = warpPos;
104 96
105 if (realizable.activePlayer == player) 97 if (realizing.getActivePlayer() == player)
106 { 98 {
107 realizing.loadMap(newMapEntity); 99 realizing.loadMap(newMapEntity);
108 } 100 }
diff --git a/src/systems/pondering.cpp b/src/systems/pondering.cpp index a3eb36d..d841679 100644 --- a/src/systems/pondering.cpp +++ b/src/systems/pondering.cpp
@@ -6,7 +6,6 @@
6#include "components/transformable.h" 6#include "components/transformable.h"
7#include "components/orientable.h" 7#include "components/orientable.h"
8#include "components/mappable.h" 8#include "components/mappable.h"
9#include "components/realizable.h"
10#include "components/playable.h" 9#include "components/playable.h"
11#include "systems/orienting.h" 10#include "systems/orienting.h"
12#include "systems/playing.h" 11#include "systems/playing.h"
@@ -485,11 +484,8 @@ void PonderingSystem::detectCollisionsInDirection(
485 CollisionResult& result) 484 CollisionResult& result)
486{ 485{
487 // Get map data. 486 // Get map data.
488 auto& realizable = game_.getEntityManager(). 487 id_type mapEntity =
489 getComponent<RealizableComponent>( 488 game_.getSystemManager().getSystem<RealizingSystem>().getActiveMap();
490 game_.getSystemManager().getSystem<RealizingSystem>().getSingleton());
491
492 id_type mapEntity = realizable.activeMap;
493 489
494 auto& mappable = game_.getEntityManager(). 490 auto& mappable = game_.getEntityManager().
495 getComponent<MappableComponent>(mapEntity); 491 getComponent<MappableComponent>(mapEntity);
diff --git a/src/systems/realizing.cpp b/src/systems/realizing.cpp index 2ee5897..7f5aefb 100644 --- a/src/systems/realizing.cpp +++ b/src/systems/realizing.cpp
@@ -6,7 +6,6 @@
6#include "game.h" 6#include "game.h"
7#include "consts.h" 7#include "consts.h"
8#include "animation.h" 8#include "animation.h"
9#include "components/realizable.h"
10#include "components/mappable.h" 9#include "components/mappable.h"
11#include "components/animatable.h" 10#include "components/animatable.h"
12#include "components/playable.h" 11#include "components/playable.h"
@@ -30,25 +29,21 @@ inline xmlChar* getProp(xmlNodePtr node, const char* attr)
30} 29}
31 30
32// TODO: neither the XML doc nor any of the emplaced entities are properly 31// TODO: neither the XML doc nor any of the emplaced entities are properly
33// destroyed if this method throws an exception. 32// destroyed if this constructor throws an exception.
34EntityManager::id_type RealizingSystem::initSingleton( 33RealizingSystem::RealizingSystem(
34 Game& game,
35 std::string worldFile, 35 std::string worldFile,
36 std::string prototypeFile) 36 std::string prototypeFile) :
37 System(game),
38 worldFile_(std::move(worldFile)),
39 prototypeFile_(std::move(prototypeFile))
37{ 40{
38 id_type world = game_.getEntityManager().emplaceEntity();
39
40 auto& realizable = game_.getEntityManager().
41 emplaceComponent<RealizableComponent>(world);
42
43 realizable.worldFile = worldFile;
44 realizable.prototypeFile = prototypeFile;
45
46 auto& mapping = game_.getSystemManager().getSystem<MappingSystem>(); 41 auto& mapping = game_.getSystemManager().getSystem<MappingSystem>();
47 42
48 xmlChar* key = nullptr; 43 xmlChar* key = nullptr;
49 44
50 // Create a mapping between prototype names and the XML trees defining them. 45 // Create a mapping between prototype names and the XML trees defining them.
51 xmlDocPtr protoXml = xmlParseFile(prototypeFile.c_str()); 46 xmlDocPtr protoXml = xmlParseFile(prototypeFile_.c_str());
52 if (protoXml == nullptr) 47 if (protoXml == nullptr)
53 { 48 {
54 throw std::invalid_argument("Cannot find prototypes file"); 49 throw std::invalid_argument("Cannot find prototypes file");
@@ -82,7 +77,7 @@ EntityManager::id_type RealizingSystem::initSingleton(
82 } 77 }
83 78
84 // Create entities from the world definition. 79 // Create entities from the world definition.
85 xmlDocPtr doc = xmlParseFile(worldFile.c_str()); 80 xmlDocPtr doc = xmlParseFile(worldFile_.c_str());
86 if (doc == nullptr) 81 if (doc == nullptr)
87 { 82 {
88 throw std::invalid_argument("Cannot find world file"); 83 throw std::invalid_argument("Cannot find world file");
@@ -100,15 +95,15 @@ EntityManager::id_type RealizingSystem::initSingleton(
100 } 95 }
101 96
102 key = getProp(top, "startx"); 97 key = getProp(top, "startx");
103 realizable.startingPos.x() = atoi(reinterpret_cast<char*>(key)); 98 startingPos_.x() = atoi(reinterpret_cast<char*>(key));
104 xmlFree(key); 99 xmlFree(key);
105 100
106 key = getProp(top, "starty"); 101 key = getProp(top, "starty");
107 realizable.startingPos.y() = atoi(reinterpret_cast<char*>(key)); 102 startingPos_.y() = atoi(reinterpret_cast<char*>(key));
108 xmlFree(key); 103 xmlFree(key);
109 104
110 key = getProp(top, "startmap"); 105 key = getProp(top, "startmap");
111 realizable.startingMapId = atoi(reinterpret_cast<char*>(key)); 106 startingMapId_ = atoi(reinterpret_cast<char*>(key));
112 xmlFree(key); 107 xmlFree(key);
113 108
114 for (xmlNodePtr node = top->xmlChildrenNode; 109 for (xmlNodePtr node = top->xmlChildrenNode;
@@ -291,78 +286,62 @@ EntityManager::id_type RealizingSystem::initSingleton(
291 286
292 mapping.generateBoundaries(map); 287 mapping.generateBoundaries(map);
293 288
294 realizable.maps.insert(map); 289 entityByMapId_[mappable.mapId] = map;
295 realizable.entityByMapId[mappable.mapId] = map;
296 } 290 }
297 } 291 }
298 292
299 xmlFreeDoc(doc); 293 xmlFreeDoc(doc);
300 xmlFreeDoc(protoXml); 294 xmlFreeDoc(protoXml);
301 295
302 loadMap(realizable.entityByMapId[realizable.startingMapId]); 296 activateMap(entityByMapId_[startingMapId_]);
303
304 return world;
305} 297}
306 298
307EntityManager::id_type RealizingSystem::getSingleton() const 299void RealizingSystem::loadMap(id_type mapEntity)
308{ 300{
309 std::set<id_type> result = 301 deactivateMap();
310 game_.getEntityManager().getEntitiesWithComponents< 302 activateMap(mapEntity);
311 RealizableComponent>();
312
313 if (result.empty())
314 {
315 throw std::logic_error("No realizable entity found");
316 } else if (result.size() > 1)
317 {
318 throw std::logic_error("Multiple realizable entities found");
319 }
320
321 return *std::begin(result);
322} 303}
323 304
324void RealizingSystem::loadMap(id_type mapEntity) 305void RealizingSystem::deactivateMap()
325{ 306{
326 id_type world = getSingleton(); 307 id_type oldMap = activeMap_;
327 308
328 auto& realizable = game_.getEntityManager(). 309 auto& oldMappable = game_.getEntityManager().
329 getComponent<RealizableComponent>(world); 310 getComponent<MappableComponent>(oldMap);
330 311
331 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>(); 312 // Deactivate any map objects from the old map.
332 auto& pondering = game_.getSystemManager().getSystem<PonderingSystem>(); 313 for (id_type prototype : oldMappable.objects)
314 {
315 leaveActiveMap(prototype);
316 }
333 317
318 // Deactivate players that were on the old map.
334 std::set<id_type> players = 319 std::set<id_type> players =
335 game_.getEntityManager().getEntitiesWithComponents< 320 game_.getEntityManager().getEntitiesWithComponents<
336 PlayableComponent>(); 321 PlayableComponent>();
337 322
338 if (realizable.hasActiveMap) 323 for (id_type player : players)
339 { 324 {
340 id_type oldMap = realizable.activeMap; 325 auto& playable = game_.getEntityManager().
341 326 getComponent<PlayableComponent>(player);
342 auto& oldMappable = game_.getEntityManager().
343 getComponent<MappableComponent>(oldMap);
344 327
345 // Deactivate any map objects from the old map. 328 if (playable.mapId == oldMap)
346 for (id_type prototype : oldMappable.objects)
347 { 329 {
348 leaveActiveMap(prototype); 330 leaveActiveMap(player);
349 } 331 }
332 }
333}
350 334
351 // Deactivate players that were on the old map. 335void RealizingSystem::activateMap(id_type mapEntity)
352 for (id_type player : players) 336{
353 { 337 auto& animating = game_.getSystemManager().getSystem<AnimatingSystem>();
354 auto& playable = game_.getEntityManager(). 338 auto& pondering = game_.getSystemManager().getSystem<PonderingSystem>();
355 getComponent<PlayableComponent>(player);
356 339
357 if (playable.mapId == oldMap) 340 std::set<id_type> players =
358 { 341 game_.getEntityManager().getEntitiesWithComponents<
359 leaveActiveMap(player); 342 PlayableComponent>();
360 }
361 }
362 }
363 343
364 realizable.hasActiveMap = true; 344 activeMap_ = mapEntity;
365 realizable.activeMap = mapEntity;
366 345
367 auto& mappable = game_.getEntityManager(). 346 auto& mappable = game_.getEntityManager().
368 getComponent<MappableComponent>(mapEntity); 347 getComponent<MappableComponent>(mapEntity);
diff --git a/src/systems/realizing.h b/src/systems/realizing.h index 595c58f..ab5a150 100644 --- a/src/systems/realizing.h +++ b/src/systems/realizing.h
@@ -2,29 +2,56 @@
2#define REALIZING_H_6853748C 2#define REALIZING_H_6853748C
3 3
4#include <string> 4#include <string>
5#include <map>
5#include "system.h" 6#include "system.h"
7#include "vector.h"
6 8
7class RealizingSystem : public System { 9class RealizingSystem : public System {
8public: 10public:
9 11
10 RealizingSystem(Game& game) : System(game)
11 {
12 }
13
14 /** 12 /**
15 * Creates the singleton realizable entity and initializes it with the 13 * Constructs the realizing system.
16 * provided world definition and map object prototype definition. 14 *
15 * Note that this must be constructed after the following system:
16 * - Mapping
17 * - Animating
18 * - Pondering
19 * - Scripting
17 */ 20 */
18 id_type initSingleton( 21 RealizingSystem(
22 Game& game,
19 std::string worldFile, 23 std::string worldFile,
20 std::string prototypeFile); 24 std::string prototypeFile);
21 25
22 /** 26 id_type getActiveMap() const
23 * Helper method that returns the entity ID of the (assumed) singleton entity 27 {
24 * with a RealizableComponent. Throws an exception if the number of realizable 28 return activeMap_;
25 * entities is not exactly one. 29 }
26 */ 30
27 id_type getSingleton() const; 31 int getStartingMapId() const
32 {
33 return startingMapId_;
34 }
35
36 vec2i getStartingPos() const
37 {
38 return startingPos_;
39 }
40
41 id_type getEntityByMapId(size_t mapId) const
42 {
43 return entityByMapId_.at(mapId);
44 }
45
46 id_type getActivePlayer() const
47 {
48 return activePlayer_;
49 }
50
51 void setActivePlayer(id_type entity)
52 {
53 activePlayer_ = entity;
54 }
28 55
29 /** 56 /**
30 * Loads the given map. 57 * Loads the given map.
@@ -41,6 +68,19 @@ public:
41 */ 68 */
42 void leaveActiveMap(id_type entity); 69 void leaveActiveMap(id_type entity);
43 70
71private:
72
73 void deactivateMap();
74
75 void activateMap(id_type mapEntity);
76
77 std::string worldFile_;
78 std::string prototypeFile_;
79 int startingMapId_;
80 vec2i startingPos_;
81 std::map<size_t, id_type> entityByMapId_;
82 id_type activeMap_;
83 id_type activePlayer_;
44}; 84};
45 85
46#endif /* end of include guard: REALIZING_H_6853748C */ 86#endif /* end of include guard: REALIZING_H_6853748C */
diff --git a/src/systems/scripting.cpp b/src/systems/scripting.cpp index dc1fff5..57c3fd5 100644 --- a/src/systems/scripting.cpp +++ b/src/systems/scripting.cpp
@@ -2,7 +2,6 @@
2#include "game.h" 2#include "game.h"
3#include "components/runnable.h" 3#include "components/runnable.h"
4#include "components/ponderable.h" 4#include "components/ponderable.h"
5#include "components/realizable.h"
6#include "components/transformable.h" 5#include "components/transformable.h"
7#include "components/playable.h" 6#include "components/playable.h"
8#include "components/mappable.h" 7#include "components/mappable.h"
@@ -24,9 +23,9 @@ ScriptingSystem::ScriptingSystem(Game& game) : System(game)
24{ 23{
25 id_type entity = game_.getEntityManager().emplaceEntity(); 24 id_type entity = game_.getEntityManager().emplaceEntity();
26 25
27 engine.open_libraries(sol::lib::base, sol::lib::coroutine); 26 engine_.open_libraries(sol::lib::base, sol::lib::coroutine);
28 27
29 engine.new_usertype<vec2d>( 28 engine_.new_usertype<vec2d>(
30 "vec2d", 29 "vec2d",
31 sol::constructors<vec2d(), vec2d(double, double)>(), 30 sol::constructors<vec2d(), vec2d(double, double)>(),
32 "x", sol::property( 31 "x", sol::property(
@@ -36,13 +35,13 @@ ScriptingSystem::ScriptingSystem(Game& game) : System(game)
36 [] (vec2d& v) -> double { return v.y(); }, 35 [] (vec2d& v) -> double { return v.y(); },
37 [] (vec2d& v, double y) { v.y() = y; })); 36 [] (vec2d& v, double y) { v.y() = y; }));
38 37
39 engine.new_usertype<vec2i>( 38 engine_.new_usertype<vec2i>(
40 "vec2i", 39 "vec2i",
41 sol::constructors<vec2i(), vec2i(int, int)>(), 40 sol::constructors<vec2i(), vec2i(int, int)>(),
42 "x", [] (vec2i& v) -> int& { return v.x(); }, 41 "x", [] (vec2i& v) -> int& { return v.x(); },
43 "y", [] (vec2i& v) -> int& { return v.y(); }); 42 "y", [] (vec2i& v) -> int& { return v.y(); });
44 43
45 engine.new_usertype<script_entity>( 44 engine_.new_usertype<script_entity>(
46 "entity", 45 "entity",
47 sol::constructors<script_entity(id_type)>(), 46 sol::constructors<script_entity(id_type)>(),
48 "id", &script_entity::id, 47 "id", &script_entity::id,
@@ -66,62 +65,50 @@ ScriptingSystem::ScriptingSystem(Game& game) : System(game)
66 return game_.getEntityManager(). 65 return game_.getEntityManager().
67 getComponent<PlayableComponent>(entity.id); 66 getComponent<PlayableComponent>(entity.id);
68 }, 67 },
69 "realizable",
70 [&] (script_entity& entity) -> RealizableComponent& {
71 return game_.getEntityManager().
72 getComponent<RealizableComponent>(entity.id);
73 },
74 "prototypable", 68 "prototypable",
75 [&] (script_entity& entity) -> PrototypableComponent& { 69 [&] (script_entity& entity) -> PrototypableComponent& {
76 return game_.getEntityManager(). 70 return game_.getEntityManager().
77 getComponent<PrototypableComponent>(entity.id); 71 getComponent<PrototypableComponent>(entity.id);
78 }); 72 });
79 73
80 engine.new_usertype<TransformableComponent>( 74 engine_.new_usertype<TransformableComponent>(
81 "transformable", 75 "transformable",
82 "pos", &TransformableComponent::pos); 76 "pos", &TransformableComponent::pos);
83 77
84 engine.new_usertype<PonderableComponent>( 78 engine_.new_usertype<PonderableComponent>(
85 "ponderable", 79 "ponderable",
86 "vel", &PonderableComponent::vel, 80 "vel", &PonderableComponent::vel,
87 "accel", &PonderableComponent::accel); 81 "accel", &PonderableComponent::accel);
88 82
89 engine.new_usertype<MappableComponent>( 83 engine_.new_usertype<MappableComponent>(
90 "mappable", 84 "mappable",
91 "mapId", &MappableComponent::mapId); 85 "mapId", &MappableComponent::mapId);
92 86
93 engine.new_usertype<PlayableComponent>( 87 engine_.new_usertype<PlayableComponent>(
94 "playable", 88 "playable",
95 "checkpointPos", &PlayableComponent::checkpointPos, 89 "checkpointPos", &PlayableComponent::checkpointPos,
96 "checkpointMapId", &PlayableComponent::checkpointMapId, 90 "checkpointMapId", &PlayableComponent::checkpointMapId,
97 "checkpointMapObject", &PlayableComponent::checkpointMapObject, 91 "checkpointMapObject", &PlayableComponent::checkpointMapObject,
98 "checkpointMapObjectIndex", &PlayableComponent::checkpointMapObjectIndex); 92 "checkpointMapObjectIndex", &PlayableComponent::checkpointMapObjectIndex);
99 93
100 engine.new_usertype<RealizableComponent>( 94 engine_.new_usertype<PrototypableComponent>(
101 "realizable",
102 "activeMap", &RealizableComponent::activeMap);
103
104 engine.new_usertype<PrototypableComponent>(
105 "prototypable", 95 "prototypable",
106 "mapObjectIndex", &PrototypableComponent::mapObjectIndex, 96 "mapObjectIndex", &PrototypableComponent::mapObjectIndex,
107 "prototypeId", &PrototypableComponent::prototypeId); 97 "prototypeId", &PrototypableComponent::prototypeId);
108 98
109 engine.new_usertype<RealizingSystem>( 99 engine_.new_usertype<RealizingSystem>(
110 "realizing", 100 "realizing",
111 "singleton", 101 "activeMap", sol::property(&RealizingSystem::getActiveMap));
112 [&] (RealizingSystem& realizing) -> script_entity {
113 return realizing.getSingleton();
114 });
115 102
116 engine.set_function( 103 engine_.set_function(
117 "realizing", 104 "realizing",
118 [&] () { 105 [&] () {
119 return game_.getSystemManager().getSystem<RealizingSystem>(); 106 return game_.getSystemManager().getSystem<RealizingSystem>();
120 }); 107 });
121 108
122 engine.script_file("scripts/common.lua"); 109 engine_.script_file("scripts/common.lua");
123 engine.script_file("scripts/movplat.lua"); 110 engine_.script_file("scripts/movplat.lua");
124 engine.script_file("scripts/checkpoint.lua"); 111 engine_.script_file("scripts/checkpoint.lua");
125} 112}
126 113
127void ScriptingSystem::tick(double dt) 114void ScriptingSystem::tick(double dt)
@@ -177,7 +164,7 @@ EntityManager::id_type ScriptingSystem::runScript(
177 std::unique_ptr<sol::thread>( 164 std::unique_ptr<sol::thread>(
178 new sol::thread( 165 new sol::thread(
179 sol::thread::create( 166 sol::thread::create(
180 engine.lua_state()))); 167 engine_.lua_state())));
181 168
182 runnable.callable = 169 runnable.callable =
183 std::unique_ptr<sol::coroutine>( 170 std::unique_ptr<sol::coroutine>(
diff --git a/src/systems/scripting.h b/src/systems/scripting.h index d5380f1..e330316 100644 --- a/src/systems/scripting.h +++ b/src/systems/scripting.h
@@ -22,7 +22,7 @@ private:
22 template <typename... Args> 22 template <typename... Args>
23 id_type runScript(std::string event, id_type entity, Args&&... args); 23 id_type runScript(std::string event, id_type entity, Args&&... args);
24 24
25 sol::state engine; 25 sol::state engine_;
26}; 26};
27 27
28#endif /* end of include guard: AUTOMATING_H_E6E5D76E */ 28#endif /* end of include guard: AUTOMATING_H_E6E5D76E */