From 046ee24a341468e9b3ea2983a731dbce18b52ac6 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 13 May 2018 11:00:02 -0400 Subject: Integrated RealizableComponent into RealizingSystem --- src/systems/scripting.cpp | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) (limited to 'src/systems/scripting.cpp') 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 @@ #include "game.h" #include "components/runnable.h" #include "components/ponderable.h" -#include "components/realizable.h" #include "components/transformable.h" #include "components/playable.h" #include "components/mappable.h" @@ -24,9 +23,9 @@ ScriptingSystem::ScriptingSystem(Game& game) : System(game) { id_type entity = game_.getEntityManager().emplaceEntity(); - engine.open_libraries(sol::lib::base, sol::lib::coroutine); + engine_.open_libraries(sol::lib::base, sol::lib::coroutine); - engine.new_usertype( + engine_.new_usertype( "vec2d", sol::constructors(), "x", sol::property( @@ -36,13 +35,13 @@ ScriptingSystem::ScriptingSystem(Game& game) : System(game) [] (vec2d& v) -> double { return v.y(); }, [] (vec2d& v, double y) { v.y() = y; })); - engine.new_usertype( + engine_.new_usertype( "vec2i", sol::constructors(), "x", [] (vec2i& v) -> int& { return v.x(); }, "y", [] (vec2i& v) -> int& { return v.y(); }); - engine.new_usertype( + engine_.new_usertype( "entity", sol::constructors(), "id", &script_entity::id, @@ -66,62 +65,50 @@ ScriptingSystem::ScriptingSystem(Game& game) : System(game) return game_.getEntityManager(). getComponent(entity.id); }, - "realizable", - [&] (script_entity& entity) -> RealizableComponent& { - return game_.getEntityManager(). - getComponent(entity.id); - }, "prototypable", [&] (script_entity& entity) -> PrototypableComponent& { return game_.getEntityManager(). getComponent(entity.id); }); - engine.new_usertype( + engine_.new_usertype( "transformable", "pos", &TransformableComponent::pos); - engine.new_usertype( + engine_.new_usertype( "ponderable", "vel", &PonderableComponent::vel, "accel", &PonderableComponent::accel); - engine.new_usertype( + engine_.new_usertype( "mappable", "mapId", &MappableComponent::mapId); - engine.new_usertype( + engine_.new_usertype( "playable", "checkpointPos", &PlayableComponent::checkpointPos, "checkpointMapId", &PlayableComponent::checkpointMapId, "checkpointMapObject", &PlayableComponent::checkpointMapObject, "checkpointMapObjectIndex", &PlayableComponent::checkpointMapObjectIndex); - engine.new_usertype( - "realizable", - "activeMap", &RealizableComponent::activeMap); - - engine.new_usertype( + engine_.new_usertype( "prototypable", "mapObjectIndex", &PrototypableComponent::mapObjectIndex, "prototypeId", &PrototypableComponent::prototypeId); - engine.new_usertype( + engine_.new_usertype( "realizing", - "singleton", - [&] (RealizingSystem& realizing) -> script_entity { - return realizing.getSingleton(); - }); + "activeMap", sol::property(&RealizingSystem::getActiveMap)); - engine.set_function( + engine_.set_function( "realizing", [&] () { return game_.getSystemManager().getSystem(); }); - engine.script_file("scripts/common.lua"); - engine.script_file("scripts/movplat.lua"); - engine.script_file("scripts/checkpoint.lua"); + engine_.script_file("scripts/common.lua"); + engine_.script_file("scripts/movplat.lua"); + engine_.script_file("scripts/checkpoint.lua"); } void ScriptingSystem::tick(double dt) @@ -177,7 +164,7 @@ EntityManager::id_type ScriptingSystem::runScript( std::unique_ptr( new sol::thread( sol::thread::create( - engine.lua_state()))); + engine_.lua_state()))); runnable.callable = std::unique_ptr( -- cgit 1.4.1