Orxonox  0.0.5 Codename: Arcturus
Trigger.h
Go to the documentation of this file.
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 
35 #ifndef _Trigger_H__
36 #define _Trigger_H__
37 
38 #include "objects/ObjectsPrereqs.h"
39 
40 #include <set>
41 #include <queue>
42 
43 #include "tools/BillboardSet.h"
44 
45 #include "TriggerBase.h"
46 
47 namespace orxonox
48 {
49 
80  {
81  public:
82  Trigger(Context* context); // Constructor. Registers and initializes the object.
83  virtual ~Trigger();
84 
85  virtual void tick(float dt);
86 
91  inline bool isActive(void) const
92  { return this->bActive_; }
93 
94  void delayChanged(void); // React to a change in delay.
95 
96  static void debugFlares(bool bVisible); // Set the visibility of all debug billboards of all Triggers.
97  virtual void changedVisibility(); // React to a change of visibility of the trigger by adjusting the visibility of the debug billboards.
98 
99  protected:
104  inline bool isTriggered()
105  { return this->isTriggered(this->mode_); }
106  virtual bool isTriggered(TriggerMode mode); // Check whether the Trigger should be triggered, given only its sub-triggers, given a specific mode.
107  virtual void triggered(bool bIsTriggered); // Fires an event with the input triggered state.
108 
109  private:
110  bool switchState(); // Switch (toggle) the activity (to the outside the triggered state) of the trigger.
111  void storeState(); // Stores the state in the queue.
112 
113  bool checkAnd(); // Check whether all the sub-triggers of this Trigger are active.
114  bool checkOr(); // Check whether at least one of the sub-triggers of this Trigger is active.
115  bool checkXor(); // Check whether exactly one of the sub-triggers of this Trigger is active.
116 
117  void setBillboardColour(const ColourValue& colour); // Set the colour of the debug billboard.
118 
119  bool bActive_;
120  bool bTriggered_;
121 
125 
127 
128  std::queue<std::pair<float, char>> stateChanges_;
129  };
130 
131 }
132 
133 #endif /* _Trigger_H__ */
#define _ObjectsExport
Definition: ObjectsPrereqs.h:60
BillboardSet debugBillboard_
A set of debug billboards to visualize the state of the trigger.
Definition: Trigger.h:126
TriggerMode
The different modes the trigger can be in.
Definition: TriggerBase.h:54
float timeSinceLastEvent_
The time since the last event came in.
Definition: Trigger.h:124
Ogre::ColourValue colour(const btVector3 &color, btScalar alpha)
Definition: OgreBulletUtils.h:41
float remainingTime_
The time until the next state (in the queue) takes effect.
Definition: Trigger.h:123
A Trigger is an object that can either be active or inactive, with a specified behavior how to switch...
Definition: Trigger.h:79
The TriggerBase class is a base class for the two types of triggers, the (normal) Triggers and the Mu...
Definition: TriggerBase.h:70
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
char latestState_
Temporarily stores a state consisting of whether the trigger is triggeres at the first bit (least sig...
Definition: Trigger.h:122
bool bActive_
Whether the trigger is active (to the outside triggered).
Definition: Trigger.h:119
bool bTriggered_
Whether the trigger is triggered (to the inside).
Definition: Trigger.h:120
Definition: Context.h:45
Shared library macros, enums, constants and forward declarations for the objects module ...
Definition: BillboardSet.h:37
bool isTriggered()
Check whether the Trigger is triggered according to its mode.
Definition: Trigger.h:104
std::queue< std::pair< float, char > > stateChanges_
A queue of state changes (in the same format as latestState_) paired with the time they will take eff...
Definition: Trigger.h:128
bool isActive(void) const
Check whether the Trigger is active.
Definition: Trigger.h:91
Definition of the TriggerBase class.