From 5e48cf6333aca7af6854d79194f138d57ce0b5e1 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 14 May 2018 18:40:54 -0400 Subject: Specialized treatment of behavior scripts The AutomatableComponent now links to the Runnable entity representing the behavior script. Also reordered the SystemManager and EntityManager members of the Game class such that the EntityManager is destroyed before the SystemManager is. This fixes a bug where the destruction of a component has some affect on the state of a system. Specifically, if the ScriptingSystem (and thus the Lua state) is destroyed before the EntityManager is and there are any Runnable entities, the game will crash when trying to destroy them. --- src/systems/scripting.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/systems/scripting.h') diff --git a/src/systems/scripting.h b/src/systems/scripting.h index e330316..b119c3f 100644 --- a/src/systems/scripting.h +++ b/src/systems/scripting.h @@ -13,14 +13,20 @@ public: void killScript(id_type entity); - id_type runBehaviorScript(id_type entity); + void startBehavior(id_type entity); + + void stopBehavior(id_type entity); void onTouch(id_type entity, id_type player); private: template - id_type runScript(std::string event, id_type entity, Args&&... args); + sol::optional runScript( + std::string table, + std::string event, + id_type entity, + Args&&... args); sol::state engine_; }; -- cgit 1.4.1