blob: 18850b31ed53fb459e5d95b9833eac49242057ba (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#ifndef SCRIPT_SYSTEM_H_FD8A95B3
#define SCRIPT_SYSTEM_H_FD8A95B3
#include <sol/sol.hpp>
#include <memory>
#include <set>
#include <list>
#include <string>
#include "system.h"
class Game;
class ScriptSystem : public System {
public:
static constexpr SystemKey Key = SystemKey::Script;
explicit ScriptSystem(Game& game);
void tick(double dt) override;
void runScript(std::string mapName, std::string scriptName);
void runDebugScript(std::string script);
private:
struct Script {
std::unique_ptr<sol::thread> runner;
std::unique_ptr<sol::coroutine> callable;
};
Game& game_;
sol::state engine_;
std::list<Script> scripts_;
std::set<std::string> loadedScripts_;
};
#endif /* end of include guard: SCRIPT_SYSTEM_H_FD8A95B3 */
|