Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.h @ 2029

Last change on this file since 2029 was 2029, checked in by landauf, 16 years ago

some changes in Trigger and DistanceTrigger

File size: 3.5 KB
RevLine 
[1383]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Benjamin Knecht
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _Trigger_H__
30#define _Trigger_H__
31
[1541]32#include <set>
[1693]33#include <queue>
[1383]34
35#include "OrxonoxPrereqs.h"
36
[2027]37#include "objects/worldentities/PositionableEntity.h"
[2013]38#include "tools/BillboardSet.h"
[1693]39
[2029]40namespace orxonox
41{
[1383]42  enum TriggerMode
43  {
[1671]44    TM_EventTriggerAND,
45    TM_EventTriggerOR,
46    TM_EventTriggerXOR,
[1383]47  };
48
[1961]49  class _OrxonoxExport Trigger : public PositionableEntity
[1383]50  {
51    public:
[2019]52      Trigger(BaseObject* creator);
[1383]53      ~Trigger();
54
[1969]55      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
56      virtual void tick(float dt);
57
58      inline bool isActive() const
59        { return bActive_; }
60
[2029]61      void addTrigger(Trigger* trigger);
[1954]62      const Trigger* getTrigger(unsigned int index) const;
[1969]63
[2029]64      void setMode(const std::string& modeName);
65      inline void setMode(TriggerMode mode)
66        { this->mode_ = mode; }
[1969]67      inline TriggerMode getMode() const
68        { return mode_; }
69
[2029]70      inline void setInvert(bool bInvert)
71        { this->bInvertMode_ = bInvert; }
72      inline bool getInvert() const
73        { return this->bInvertMode_; }
74
75      inline void setSwitch(bool bSwitch)
76        { this->bSwitch_ = bSwitch; }
77      inline bool getSwitch() const
78        { return this->bSwitch_; }
79
80      inline void setStayActive(bool bStayActive)
81        { this->bStayActive_ = bStayActive; }
82      inline bool getStayActive() const
83        { return this->bStayActive_; }
84
[1969]85      inline void setActivations(int activations)
86        { this->remainingActivations_ = activations; }
[2029]87      inline int getActivations() const
88        { return this->remainingActivations_; }
89
[1693]90      void setDelay(float delay);
[2029]91      inline float getDelay() const
92        { return this->delay_; }
93
[1693]94      bool switchState();
[1383]95
[1969]96      static void debugFlares(bool bVisible);
97      virtual void changedVisibility();
98
[2029]99    protected:
100      inline bool isTriggered() { return this->isTriggered(this->mode_); }
101      virtual bool isTriggered(TriggerMode mode);
102
[1383]103    private:
[1541]104      bool checkAnd();
105      bool checkOr();
[1671]106      bool checkXor();
[2029]107      void setBillboardColour(const ColourValue& colour);
[1851]108      void storeState();
[2029]109      std::string getModeString() const;
[1541]110
[2029]111      bool bActive_;
112      bool bTriggered_;
[1851]113
[1383]114      TriggerMode mode_;
[1693]115      bool bInvertMode_;
[2029]116      bool bSwitch_;
117      bool bStayActive_;
[1693]118      float delay_;
[1851]119      int remainingActivations_;
[2029]120
[1693]121      char latestState_;
[2029]122      float remainingTime_;
123      float timeSinceLastEvent_;
124
125//      bool bUpdating_;
126      BillboardSet debugBillboard_;
127
128      std::set<Trigger*> children_;
129      std::queue<std::pair<float, char> > stateChanges_;
[1383]130  };
131
132}
133
134#endif /* _Trigger_H__ */
Note: See TracBrowser for help on using the repository browser.