1 | /*! |
---|
2 | * @file scrip_trigger.h |
---|
3 | * triggeres a script |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _SCRIPT_TRIGGER_H |
---|
7 | #define _SCRIPT_TRIGGER_H |
---|
8 | |
---|
9 | #include <string> |
---|
10 | |
---|
11 | #include "world_entity.h" |
---|
12 | #include "loading/load_param.h" |
---|
13 | #include "vector.h" |
---|
14 | #include "script_manager.h" |
---|
15 | #include "script.h" |
---|
16 | #include "script_class.h" |
---|
17 | |
---|
18 | class ScriptTrigger : public WorldEntity |
---|
19 | { |
---|
20 | public: |
---|
21 | ScriptTrigger(const TiXmlElement* root = NULL); |
---|
22 | ~ScriptTrigger(); |
---|
23 | |
---|
24 | ///LOADING |
---|
25 | virtual void loadParams(const TiXmlElement* root); |
---|
26 | |
---|
27 | |
---|
28 | /// DO WORK |
---|
29 | virtual void tick(float timestep); |
---|
30 | virtual void executeAction(float timestep); |
---|
31 | void testScriptingFramework(); |
---|
32 | |
---|
33 | /// SET MEMBER |
---|
34 | void setTarget(const std::string& targetName); |
---|
35 | void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target; } |
---|
36 | void setTriggerParent(const std::string& name); |
---|
37 | void setCallOnce(const bool call) { this->callOnce = call; } |
---|
38 | void setTriggerLasts(const bool lasts) { this->triggerLasts = lasts; } |
---|
39 | void setInvert(const bool inv) { this->invert = invert; } |
---|
40 | void setRadius(const float radius) { if(radius>0) this->radius = radius; } |
---|
41 | void setDelay(const float time){if(delay>0) this->delay = delay; } |
---|
42 | void setScript(const std::string& file); |
---|
43 | void setFunction(const std::string& function){ this->functionName = function;} |
---|
44 | void setDebugDraw(const bool draw) { this->doDebugDraw = draw; } |
---|
45 | void setAddToScript(const bool add) { this->addToScript = add; } |
---|
46 | |
---|
47 | ///DRAWING |
---|
48 | void draw()const{if(doDebugDraw)this->debugDraw();}; |
---|
49 | |
---|
50 | private: |
---|
51 | |
---|
52 | WorldEntity* target; |
---|
53 | bool callOnce; |
---|
54 | bool triggerLasts; |
---|
55 | bool invert; |
---|
56 | float radius; |
---|
57 | float delay; |
---|
58 | Script* script; |
---|
59 | std::string functionName; |
---|
60 | bool doDebugDraw; |
---|
61 | bool addToScript; |
---|
62 | //for internal use |
---|
63 | bool scriptCalled; |
---|
64 | bool scriptIsOk; |
---|
65 | bool actionFinished; |
---|
66 | int returnCount; //TODO: set return count correctly |
---|
67 | |
---|
68 | }; |
---|
69 | |
---|
70 | |
---|
71 | #endif |
---|