Orxonox  0.0.5 Codename: Arcturus
DistanceTrigger.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  * Damian 'Mozork' Frick
26  *
27  */
28 
35 #ifndef _DistanceTrigger_H__
36 #define _DistanceTrigger_H__
37 
38 #include "objects/ObjectsPrereqs.h"
39 
40 #include <set>
41 
42 #include "core/ClassTreeMask.h"
43 
45 
46 #include "Trigger.h"
47 
48 namespace orxonox
49 {
50 
58  off,
59  identify,
60  exclude
61  };
62 
94  {
95  public:
96  DistanceTrigger(Context* context); // Constructor. Registers and initializes the object.
97  virtual ~DistanceTrigger();
98 
99  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; // Method for creating a DistanceTrigger object through XML.
100 
101  void addTarget(const std::string& targets); // Add some target to the DistanceTrigger.
102  void removeTarget(const std::string& targets); // Remove some target from the DistanceTrigger.
103 
108  inline void setDistance(float distance)
109  { this->distance_ = distance; }
114  inline float getDistance() const
115  { return this->distance_; }
116 
117  void setBeaconModeDirect(DistanceTriggerBeaconMode mode); // Set the beacon mode.
123  { return this->beaconMode_; }
124  void setBeaconMode(const std::string& mode); // Set the beacon mode.
125  const std::string& getBeaconMode(void) const; // Get the beacon mode.
126 
131  inline void setTargetName(const std::string& targetname)
132  { this->targetName_ = targetname; }
137  inline const std::string& getTargetName(void)
138  { return this->targetName_; }
139 
140  bool checkDistance(); // Check, whether there are entities that are targets of this DistanceTrigger in its range.
141 
142  protected:
143  virtual bool isTriggered(TriggerMode mode) override; // Check whether the DistanceTrigger is triggered.
147  virtual void notifyMaskUpdate() {}
148 
150 
151  private:
156 
157  float distance_;
158 
162 
164  };
165 }
166 
167 #endif /* _DistanceTrigger_H__ */
#define _ObjectsExport
Definition: ObjectsPrereqs.h:60
float getDistance() const
Get the range of the DistanceTrigger.
Definition: DistanceTrigger.h:114
The ClassTreeMask is a set of rules, containing the information for each class whether it&#39;s included ...
Definition: ClassTreeMask.h:187
The DistanceTrigger is in identify-mode.
TriggerMode
The different modes the trigger can be in.
Definition: TriggerBase.h:54
::std::string string
Definition: gtest-port.h:756
Declaration of the ClassTreeMask, ClassTreeMaskNode, and ClassTreeMaskIterator classes.
Definition of the Trigger class.
WeakPtr wraps a pointer to an object, which becomes nullptr if the object is deleted.
Definition: CorePrereqs.h:236
ClassTreeMask beaconMask_
A mask, that only accepts DistanceTriggerBeacons.
Definition: DistanceTrigger.h:161
void setTargetName(const std::string &targetname)
Set the name a DistanceTriggerBeacon needs to have to make the DistanceTrigger react to it if in beac...
Definition: DistanceTrigger.h:131
The DistanceMultiTrigger is not in beacon-mode.
PlayerTrigger is an interface if implemented by a specific trigger can be used to recover the Player ...
Definition: PlayerTrigger.h:54
xmlelement
Definition: Super.h:519
A Trigger is an object that can either be active or inactive, with a specified behavior how to switch...
Definition: Trigger.h:79
static const std::string beaconModeOff_s
Strings for the beacon modes.
Definition: DistanceTrigger.h:153
The DistanceTrigger is a Trigger that triggers whenever an object (that is of the specified target ty...
Definition: DistanceTrigger.h:93
DistanceTriggerBeaconMode beaconMode_
The beacon mode.
Definition: DistanceTrigger.h:159
const std::string & getTargetName(void)
Get the target name.
Definition: DistanceTrigger.h:137
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Mode
Definition: CorePrereqs.h:102
virtual void notifyMaskUpdate()
Notifies interested parties about a change of the DistanceTrigger&#39;s target mask.
Definition: DistanceTrigger.h:147
ClassTreeMask targetMask_
The target mask, specifies by which types of objects the DistanceTrigger can be triggered.
Definition: DistanceTrigger.h:149
WeakPtr< WorldEntity > cache_
Caches the entity that triggered the DistanceTrigger last.
Definition: DistanceTrigger.h:163
Definition: Context.h:45
static const std::string beaconModeIdentify_s
Definition: DistanceTrigger.h:154
static const std::string beaconModeExlcude_s
Definition: DistanceTrigger.h:155
Shared library macros, enums, constants and forward declarations for the objects module ...
void setDistance(float distance)
Set the range of the DistanceTrigger.
Definition: DistanceTrigger.h:108
Definition of the PlayerTrigger class.
DistanceTriggerBeaconMode
Enum for the beacon mode of the DistanceTrigger.
Definition: DistanceTrigger.h:57
float distance_
The range of the DistanceTrigger.
Definition: DistanceTrigger.h:157
std::string targetName_
The name a DistanceTriggerBeacon needs to have to make the DistanceTrigger react to it if in beacon-m...
Definition: DistanceTrigger.h:160
DistanceTriggerBeaconMode getBeaconModeDirect(void) const
Get the beacon mode.
Definition: DistanceTrigger.h:122