Last change
on this file since 8173 was
8171,
checked in by snellen, 18 years ago
|
scripttrigger implemented. todo: make loadParam work
|
File size:
1.5 KB
|
Line | |
---|
1 | #ifndef _SCRIPT_MANAGER_H |
---|
2 | #define _SCRIPT_MANAGER_H |
---|
3 | |
---|
4 | #include <list> |
---|
5 | #include <string> |
---|
6 | |
---|
7 | #include "script.h" |
---|
8 | #include "base_object.h" |
---|
9 | #include "luaincl.h" |
---|
10 | #include "loading/load_param.h" |
---|
11 | |
---|
12 | |
---|
13 | //!< Contains the name of a lua script file and a list of all objects that the script needs |
---|
14 | struct LuaScript |
---|
15 | { |
---|
16 | std::string name; |
---|
17 | std::list<std::string> objectList; |
---|
18 | Script script; |
---|
19 | }; |
---|
20 | |
---|
21 | class ScriptManager : public BaseObject |
---|
22 | { |
---|
23 | public: |
---|
24 | ScriptManager(); |
---|
25 | ~ScriptManager(); |
---|
26 | |
---|
27 | inline static ScriptManager* getInstance(){if (!ScriptManager::singletonRef)ScriptManager::singletonRef = new ScriptManager();return ScriptManager::singletonRef;} |
---|
28 | |
---|
29 | virtual void loadParams(const TiXmlElement* root); |
---|
30 | void setWorld(const std::string& world) {currentWorld = world;} |
---|
31 | |
---|
32 | void tick(float timestep); |
---|
33 | |
---|
34 | void initScripts(); // initializes all scripts |
---|
35 | Script* getScriptByFile(std::string& file); |
---|
36 | |
---|
37 | private: |
---|
38 | |
---|
39 | void init(); |
---|
40 | void createScriptList(const TiXmlElement* scripts); |
---|
41 | void setCurrentScriptFile(const std::string& file); |
---|
42 | void addObjectToScript(const std::string object); |
---|
43 | |
---|
44 | bool fileIsInScriptList(const std::string& file); |
---|
45 | bool objectIsInObjectList(const std::string& object, const LuaScript& script); |
---|
46 | |
---|
47 | |
---|
48 | static ScriptManager* singletonRef; //!< Reference to this class |
---|
49 | std::list<LuaScript> scriptList; //!< The list of all scripts that the current world needs |
---|
50 | std::string currentWorld; |
---|
51 | LuaScript currentScript; //!< For temorary use |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | }; |
---|
56 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.