Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/scriptimprovements/src/world_entities/script_triggers/script_trigger.h @ 10606

Last change on this file since 10606 was 10606, checked in by snellen, 17 years ago

moved scripttrigger to the subfolder script_triggers/ in world_entities

File size: 2.1 KB
Line 
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
18class ScriptTrigger : public WorldEntity
19{
20  ObjectListDeclaration(ScriptTrigger);
21  public:
22    ScriptTrigger(const TiXmlElement* root = NULL);
23    ~ScriptTrigger();
24
25    ///LOADING
26    virtual void loadParams(const TiXmlElement* root);
27
28
29    /// DO WORK
30    virtual void tick(float timestep);
31    virtual void executeAction(float timestep);
32    void testScriptingFramework();
33
34    /// SET MEMBER
35    void setTarget(const std::string& targetName);
36    void setTarget(WorldEntity* target) { if(target!=NULL) this->target=target; }
37    void setTriggerParent(const std::string& name);
38    void setTriggerRemains(const bool lasts) { this->triggerRemains = lasts; }
39    void setActiveOnCreation(const bool avtive) { this->activeOnCreation = avtive; }
40    void setInvert(const bool inv) { this->invert = invert; }
41    void setDelay(float delay) { this->delay = delay; };
42    void setRadius(const float radius) { if(radius>0) this->radius = radius; }
43    void setScript(const std::string& file);
44    void setFunction(const std::string& function){ this->functionName = function;}
45    void setDebugDraw(const bool draw) { this->doDebugDraw = draw; }
46    void setAddToScript(const bool add) { this->addToScript = add; }
47
48    ///DRAWING
49    void draw()const{if(doDebugDraw)this->debugDraw();};
50
51  private:
52
53    WorldEntity* target;
54    bool         triggerRemains;
55    bool         activeOnCreation;
56    bool         invert;
57    float        radius;
58    float        delay;
59    Script*      script;
60    std::string  functionName;
61    bool         doDebugDraw;
62    bool         addToScript;
63    //for internal use
64    bool         scriptCalled;
65    bool         scriptIsOk;
66    bool         executionStopped;   // true when something goes wrong and the trigger has to be stopped
67    bool         scriptFinished;
68    int          returnCount;        //TODO: set return count correctly
69
70};
71
72
73#endif
Note: See TracBrowser for help on using the repository browser.