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 | |
---|
29 | /** |
---|
30 | @file DistanceTrigger.h |
---|
31 | @brief Definition of the DistanceTrigger class. |
---|
32 | @ingroup NormalTrigger |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef _DistanceTrigger_H__ |
---|
36 | #define _DistanceTrigger_H__ |
---|
37 | |
---|
38 | #include "objects/ObjectsPrereqs.h" |
---|
39 | |
---|
40 | #include <set> |
---|
41 | #include "core/ClassTreeMask.h" |
---|
42 | #include "Trigger.h" |
---|
43 | #include "interfaces/PlayerTrigger.h" |
---|
44 | |
---|
45 | namespace orxonox |
---|
46 | { |
---|
47 | |
---|
48 | /** |
---|
49 | @brief |
---|
50 | Enum for the beacon mode of the DistanceTrigger. |
---|
51 | |
---|
52 | @ingroup NormalTrigger |
---|
53 | */ |
---|
54 | namespace distanceTriggerBeaconMode |
---|
55 | { |
---|
56 | enum Value { |
---|
57 | off, |
---|
58 | identify, |
---|
59 | exclude |
---|
60 | }; |
---|
61 | } |
---|
62 | |
---|
63 | /** |
---|
64 | @brief |
---|
65 | |
---|
66 | @author |
---|
67 | Benjamin Knecht |
---|
68 | @author |
---|
69 | Damian 'Mozork' Frick |
---|
70 | |
---|
71 | @ingroup NormalTrigger |
---|
72 | */ |
---|
73 | class _ObjectsExport DistanceTrigger : public Trigger, public PlayerTrigger |
---|
74 | { |
---|
75 | public: |
---|
76 | DistanceTrigger(BaseObject* creator); |
---|
77 | virtual ~DistanceTrigger(); |
---|
78 | |
---|
79 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
80 | |
---|
81 | void addTarget(Ogre::Node* targetNode); |
---|
82 | void addTargets(const std::string& targets); |
---|
83 | void removeTarget(Ogre::Node* targetNode); |
---|
84 | void removeTargets(const std::string& targets); |
---|
85 | |
---|
86 | inline void setDistance(float distance) |
---|
87 | { this->distance_ = distance; } |
---|
88 | inline float getDistance() const |
---|
89 | { return this->distance_; } |
---|
90 | |
---|
91 | void setBeaconModeDirect(distanceTriggerBeaconMode::Value mode); //!< Set the beacon mode. |
---|
92 | /** |
---|
93 | @brief Get the beacon mode. |
---|
94 | @return Returns the mode as an enum. |
---|
95 | */ |
---|
96 | inline distanceTriggerBeaconMode::Value getBeaconModeDirect(void) const |
---|
97 | { return this->beaconMode_; } |
---|
98 | void setBeaconMode(const std::string& mode); //!< Set the beacon mode. |
---|
99 | const std::string& getBeaconMode(void) const; //!< Get the beacon mode. |
---|
100 | |
---|
101 | inline void setTargetName(const std::string& targetname) |
---|
102 | { this->targetName_ = targetname; } |
---|
103 | inline const std::string& getTargetName(void) |
---|
104 | { return this->targetName_; } |
---|
105 | |
---|
106 | bool checkDistance(); |
---|
107 | |
---|
108 | protected: |
---|
109 | virtual bool isTriggered(TriggerMode::Value mode); |
---|
110 | virtual void notifyMaskUpdate() {} |
---|
111 | |
---|
112 | ClassTreeMask targetMask_; |
---|
113 | |
---|
114 | private: |
---|
115 | //! Strings for the beacon modes. |
---|
116 | static const std::string beaconModeOff_s; |
---|
117 | static const std::string beaconModeIdentify_s; |
---|
118 | static const std::string beaconModeExlcude_s; |
---|
119 | |
---|
120 | std::set<Ogre::Node*> targetSet_; |
---|
121 | |
---|
122 | distanceTriggerBeaconMode::Value beaconMode_; |
---|
123 | std::string targetName_; |
---|
124 | ClassTreeMask* beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons. |
---|
125 | |
---|
126 | float distance_; |
---|
127 | |
---|
128 | }; |
---|
129 | } |
---|
130 | |
---|
131 | #endif /* _DistanceTrigger_H__ */ |
---|