1 | #ifndef SCRIPTABLE_CONTROLLER_H |
---|
2 | #define SCRIPTABLE_CONTROLLER_H |
---|
3 | |
---|
4 | #include <lua.hpp> |
---|
5 | #include <string> |
---|
6 | #include <list> |
---|
7 | #include <map> |
---|
8 | #include <memory> |
---|
9 | #include "scriptable_controller_api.h" |
---|
10 | #include "core/CoreIncludes.h" |
---|
11 | #include "worldentities/WorldEntity.h" |
---|
12 | #include "worldentities/ControllableEntity.h" |
---|
13 | |
---|
14 | struct lua_State; |
---|
15 | |
---|
16 | namespace orxonox |
---|
17 | { |
---|
18 | |
---|
19 | class ScriptableController : public BaseObject, public Tickable |
---|
20 | { |
---|
21 | public: |
---|
22 | explicit ScriptableController(Context *context); |
---|
23 | |
---|
24 | int runScript(const std::string &file_path); |
---|
25 | |
---|
26 | void registerWorldEntity(int id, WorldEntity *obj); |
---|
27 | void registerControllableEntity(int id, ControllableEntity *obj); |
---|
28 | |
---|
29 | WorldEntity *getWorldEntityByID(int id) const; |
---|
30 | ControllableEntity *getControllableEntityByID(int id) const; |
---|
31 | |
---|
32 | void registerTimeout(std::function<void (void)> callback, double timeout); |
---|
33 | |
---|
34 | virtual void tick(float dt) override; |
---|
35 | |
---|
36 | private: |
---|
37 | std::list<std::unique_ptr<ScriptableControllerAPI> > apis_; |
---|
38 | ControllableEntity *player_; // TODO |
---|
39 | std::map<int, WorldEntity*> worldEntities_; |
---|
40 | std::map<int, ControllableEntity*> controllabelEntities_; |
---|
41 | std::list<std::pair<std::function<void (void)>, float> > timeouts; |
---|
42 | |
---|
43 | void printLuaError(lua_State *lua); |
---|
44 | }; |
---|
45 | |
---|
46 | } |
---|
47 | |
---|
48 | #endif // SCRIPTABLE_CONTROLLER_H |
---|