summary refs log tree commit diff stats
path: root/src/components/runnable.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/runnable.h')
-rw-r--r--src/components/runnable.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/components/runnable.h b/src/components/runnable.h index 1b994fb..956bfdc 100644 --- a/src/components/runnable.h +++ b/src/components/runnable.h
@@ -4,12 +4,48 @@
4#include "component.h" 4#include "component.h"
5#include <sol.hpp> 5#include <sol.hpp>
6#include <memory> 6#include <memory>
7#include "entity_manager.h"
7 8
8class RunnableComponent : public Component { 9class RunnableComponent : public Component {
9public: 10public:
10 11
12 using id_type = EntityManager::id_type;
13
14 /**
15 * A Lua stack where the entity's script is running.
16 *
17 * NOTE: This object is called a thread, but there is no multi-threading going
18 * on.
19 *
20 * @managed_by ScriptingSystem
21 */
11 std::unique_ptr<sol::thread> runner; 22 std::unique_ptr<sol::thread> runner;
23
24 /**
25 * An entry point to the script running in the runner thread.
26 *
27 * @managed_by ScriptingSystem
28 */
12 std::unique_ptr<sol::coroutine> callable; 29 std::unique_ptr<sol::coroutine> callable;
30
31 /**
32 * Whether or not this entity represents a behavior script. A behavior script
33 * usually does not terminate on its own, and can be terminated at will by
34 * another system, usually when the automatable entity leaves the active map.
35 *
36 * @managed_by ScriptingSystem
37 */
38 bool behavior = false;
39
40 /**
41 * If this is a behavior script, this is the ID of the automatable entity that
42 * the behavior belongs to. This is required so that the ScriptingSystem can
43 * notify the automatable entity if the behavior script terminates by itself,
44 * and that it shouldn't attempt to terminate it.
45 *
46 * @managed_by ScriptingSystem
47 */
48 id_type actor;
13}; 49};
14 50
15#endif /* end of include guard: AUTOMATABLE_H_3D519131 */ 51#endif /* end of include guard: AUTOMATABLE_H_3D519131 */