Index: code/trunk/src/modules/objects/triggers/DistanceTrigger.h
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceTrigger.h	(revision 8079)
+++ code/trunk/src/modules/objects/triggers/DistanceTrigger.h	(revision 8213)
@@ -39,59 +39,131 @@
 
 #include <set>
+
 #include "core/ClassTreeMask.h"
+
+#include "interfaces/PlayerTrigger.h"
+
 #include "Trigger.h"
-#include "interfaces/PlayerTrigger.h"
 
 namespace orxonox
 {
-
+    
   /**
   @brief
-
-  @author
-    Benjamin Knecht
-  @author
-    Damian 'Mozork' Frick
-
+      Enum for the beacon mode of the DistanceTrigger.
+      
   @ingroup NormalTrigger
   */
-  class _ObjectsExport DistanceTrigger : public Trigger, public PlayerTrigger
+  namespace distanceTriggerBeaconMode
   {
-    public:
-      DistanceTrigger(BaseObject* creator);
-      virtual ~DistanceTrigger();
+      enum Value {
+          off,
+          identify,
+          exclude
+      };
+  }
 
-      virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+    /**
+    @brief
+        The DistanceTrigger is a Trigger that triggers whenever an object (that is of the specified target type) is in a specified range of the DistanceTrigger. The object can be specified further by setting the <em>beaconMode</em> and attaching a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" to the object.
+        Parameters are (additional to the ones of Trigger):
+        - @b distance Which specifies the maximum distance at which the DistanceTrigger still triggers, i.e. its range. Default is <code>100</code>.
+        - @b target Which specifies the class of objects that can trigger the DistanceTrigger. Default is <code>"Pawn"</code>.
+        - @b beaconMode Which specifies, whether the DistanceTrigger operates on @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacons" or not. If <em>off</em> the DistanceMultiTrigger works as usual. If set to <em>identify</em> the DistanceTrigger is only triggered by objects that have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon", with the same name as specified in <em>targetname</em>, attached to them. If set to <em>exclude</em> the DistanceTrigger is only triggered by objects that don't have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon", with the same name as specified in <em>targetname</em>, attached to them. Default is <em>off</em>.
+        - @b targetname Which specifies the name @ref oroxnox::DistanceTriggerBeacon "DistanceTriggerBeacons" need to have to make the DistanceTrigger react to them if it is in <em>beacon-mode</em> (the beaconMode is not <em>off</em>).
 
-      void addTarget(Ogre::Node* targetNode);
-      void addTargets(const std::string& targets);
-      void removeTarget(Ogre::Node* targetNode);
-      void removeTargets(const std::string& targets);
+        A simple DistanceTrigger could look like this:
+        @code
+        <DistanceTrigger position="0,0,0" switch="true" target="Pawn" distance="20" />
+        @endcode
 
-      inline void setTargetName(const std::string& targetname)
-        { if(targetname != "") this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; }
-      inline const std::string& getTargetName(void)
-        { return this->targetName_; }
+        An implementation that only reacts to objects with a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" attached would look like this:
+        @code
+        <DistanceTrigger position="0,0,0" target="Pawn" beaconMode="identify" targetname="beacon1" distance="30" />
+        @endcode
+        This particular DistanceTrigger would only react if an object was in range, that had a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" with the name <em>beacon1</em> attached.
 
-      inline void setDistance(float distance)
-        { this->distance_ = distance; }
-      inline float getDistance() const
-        { return this->distance_; }
+    @see Trigger
+        For more information on @ref orxonox::Trigger "Triggers".
 
-      bool checkDistance();
+    @author
+        Benjamin Knecht
+    @author
+        Damian 'Mozork' Frick
 
-    protected:
-      virtual bool isTriggered(TriggerMode::Value mode);
-      virtual void notifyMaskUpdate() {}
+    @ingroup NormalTrigger
+    */
+    class _ObjectsExport DistanceTrigger : public Trigger, public PlayerTrigger
+    {
+        public:
+            DistanceTrigger(BaseObject* creator); // Constructor. Registers and initializes the object.
+            virtual ~DistanceTrigger();
 
-      ClassTreeMask targetMask_;
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); // Method for creating a DistanceTrigger object through XML.
 
-    private:
-      std::set<Ogre::Node*> targetSet_;
-      std::string targetName_;
-      float distance_;
-      bool singleTargetMode_;
+            void addTarget(const std::string& targets); // Add some target to the DistanceTrigger.
+            void removeTarget(const std::string& targets); // Remove some target from the DistanceTrigger.
 
-  };
+            /**
+            @brief Set the range of the DistanceTrigger.
+            @param distance The range to be set.
+            */
+            inline void setDistance(float distance)
+                { this->distance_ = distance; }
+            /**
+            @brief Get the range of the DistanceTrigger.
+            @return Returns the range of the distance trigger.
+            */
+            inline float getDistance() const
+                { return this->distance_; }
+
+            void setBeaconModeDirect(distanceTriggerBeaconMode::Value mode); // Set the beacon mode.
+            /**
+            @brief Get the beacon mode.
+            @return Returns the mode as an enum.
+            */
+            inline distanceTriggerBeaconMode::Value getBeaconModeDirect(void) const
+            { return this->beaconMode_; }
+            void setBeaconMode(const std::string& mode); // Set the beacon mode.
+            const std::string& getBeaconMode(void) const; // Get the beacon mode.
+
+            /**
+            @brief Set the name a DistanceTriggerBeacon needs to have to make the DistanceTrigger react to it if in beacon-mode.
+            @param targetname The name as a string.
+            */
+            inline void setTargetName(const std::string& targetname)
+                { this->targetName_ = targetname; }
+            /**
+            @brief Get the target name.
+            @return Returns the target name as a string.
+            */
+            inline const std::string& getTargetName(void)
+                { return this->targetName_; }
+
+            bool checkDistance(); // Check, whether there are entities that are targets of this DistanceTrigger in its range.
+
+        protected:
+            virtual bool isTriggered(TriggerMode::Value mode); // Check whether the DistanceTrigger is triggered.
+            /**
+            @brief Notifies interested parties about a change of the DistanceTrigger's target mask.
+            */
+            virtual void notifyMaskUpdate() {}
+
+            ClassTreeMask targetMask_; //!< The target mask, specifies by which types of objects the DistanceTrigger can be triggered. 
+
+        private:
+            //! Strings for the beacon modes.
+            static const std::string beaconModeOff_s;
+            static const std::string beaconModeIdentify_s;
+            static const std::string beaconModeExlcude_s;
+
+            float distance_; //!< The range of the DistanceTrigger.
+            
+            distanceTriggerBeaconMode::Value beaconMode_; //!< The beacon mode.
+            std::string targetName_; //!< The name a DistanceTriggerBeacon needs to have to make the DistanceTrigger react to it if in beacon-mode.
+            ClassTreeMask* beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
+            
+            WeakPtr<WorldEntity> cache_; //!< Caches the entity that triggered the DistanceTrigger last.
+    };
 }
 
