Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/objects/triggers/Trigger.h @ 7216

Last change on this file since 7216 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 3.8 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
[5730]32#include "objects/ObjectsPrereqs.h"
[3196]33
[1541]34#include <set>
[1693]35#include <queue>
[1383]36
[3196]37#include "tools/BillboardSet.h"
[5693]38#include "tools/interfaces/Tickable.h"
[5735]39#include "worldentities/StaticEntity.h"
[1693]40
[2029]41namespace orxonox
42{
[3280]43  namespace TriggerMode
[1383]44  {
[3280]45    enum Value
46    {
47      EventTriggerAND,
48      EventTriggerOR,
49      EventTriggerXOR,
50    };
51  }
[1383]52
[5730]53  class _ObjectsExport Trigger : public StaticEntity, public Tickable
[1383]54  {
55    public:
[2019]56      Trigger(BaseObject* creator);
[2071]57      virtual ~Trigger();
[1383]58
[1969]59      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
60      virtual void tick(float dt);
61
62      inline bool isActive() const
63        { return bActive_; }
64
[2029]65      void addTrigger(Trigger* trigger);
[1954]66      const Trigger* getTrigger(unsigned int index) const;
[1969]67
[2029]68      void setMode(const std::string& modeName);
[3280]69      inline void setMode(TriggerMode::Value mode)
[2029]70        { this->mode_ = mode; }
[3280]71      inline TriggerMode::Value getMode() const
[1969]72        { return mode_; }
73
[2029]74      inline void setInvert(bool bInvert)
75        { this->bInvertMode_ = bInvert; }
76      inline bool getInvert() const
77        { return this->bInvertMode_; }
78
79      inline void setSwitch(bool bSwitch)
80        { this->bSwitch_ = bSwitch; }
81      inline bool getSwitch() const
82        { return this->bSwitch_; }
83
84      inline void setStayActive(bool bStayActive)
85        { this->bStayActive_ = bStayActive; }
86      inline bool getStayActive() const
87        { return this->bStayActive_; }
88
[1969]89      inline void setActivations(int activations)
90        { this->remainingActivations_ = activations; }
[2029]91      inline int getActivations() const
92        { return this->remainingActivations_; }
93
[3033]94      inline void setVisible(bool visibility)
95        { this->debugBillboard_.setVisible(visibility); }
96
[1693]97      void setDelay(float delay);
[2029]98      inline float getDelay() const
99        { return this->delay_; }
100
[1693]101      bool switchState();
[1383]102
[1969]103      static void debugFlares(bool bVisible);
104      virtual void changedVisibility();
105
[2029]106    protected:
107      inline bool isTriggered() { return this->isTriggered(this->mode_); }
[3280]108      virtual bool isTriggered(TriggerMode::Value mode);
[3033]109      virtual void triggered(bool bIsTriggered);
[2029]110
[1383]111    private:
[1541]112      bool checkAnd();
113      bool checkOr();
[1671]114      bool checkXor();
[2029]115      void setBillboardColour(const ColourValue& colour);
[1851]116      void storeState();
[2029]117      std::string getModeString() const;
[1541]118
[2029]119      bool bActive_;
120      bool bTriggered_;
[2069]121      bool bFirstTick_;
[1851]122
[3280]123      TriggerMode::Value mode_;
[1693]124      bool bInvertMode_;
[2029]125      bool bSwitch_;
126      bool bStayActive_;
[1693]127      float delay_;
[1851]128      int remainingActivations_;
[2029]129
[1693]130      char latestState_;
[2029]131      float remainingTime_;
132      float timeSinceLastEvent_;
133
134//      bool bUpdating_;
135      BillboardSet debugBillboard_;
136
137      std::set<Trigger*> children_;
138      std::queue<std::pair<float, char> > stateChanges_;
[1383]139  };
140
141}
142
143#endif /* _Trigger_H__ */
Note: See TracBrowser for help on using the repository browser.