Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 9, 2011, 3:33:06 PM (13 years ago)
Author:
dafrick
Message:

Adding changes made to DistanceTrigger also in trunk.
Also documenting trigger.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h

    r7601 r8213  
    5151    /**
    5252    @brief
    53         The DistanceMultiTrigger is a MultiTrigger that triggers whenever an object (that is of the specified target type) is in a specified range of the DistanceMultiTrigger. The object can be specified further by adding a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" (by just attaching it) to the objects that can trigger this DistanceMultiTrigger and specify the name of the @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" with the parameter <em>targetname</em> and only objects that have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" with that name will trigger the DistanceMultiTrigger.
     53        Enum for the beacon mode of the DistanceMultiTrigger.
     54       
     55    @ingroup MultiTrigger
     56    */
     57    namespace distanceMultiTriggerBeaconMode
     58    {
     59        enum Value {
     60            off, //!< The DistanceMultiTrigger is not in <em>beacon-mode</em>.
     61            identify, //!< The DistanceTrigger is in <em>identify-mode</em>.
     62            exclude //!< The DistanceTrigger is in <em>exclude-mode</em>.
     63        };
     64    }
     65
     66    /**
     67    @brief
     68        The DistanceMultiTrigger is a MultiTrigger that triggers whenever an object (that is of the specified target type) is in a specified range of the DistanceMultiTrigger. The object can be specified further by setting the <em>beaconMode</em> and attaching a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" to the object.
    5469        Parameters are (additional to the ones of MultiTrigger):
    55         - @b distance Which specifies the maximum distance at which the DistanceMultiTrigger still triggers. Default is 100.
    56         - @b targetname Which, if not left blank, causes the DistancMultiTrigger to be in <em>single-target</em> mode, meaning, that it only reacts to objects that have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" (therefore the target has to be set to @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" for it to work), with the name specified by <em>targetname</em>, attached.
     70        - @b distance Which specifies the maximum distance at which the DistanceMultiTrigger still triggers. Default is <code>100</code>.
     71        - @b beaconMode Which specifies, whether the DistanceMultiTrigger operates on @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacons" or not. If <em>off</em> the DistanceMultiTrigger works as usual. If set to <em>identify</em> the DistanceMultiTrigger 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 DistanceMultiTrigger 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>.
     72        - @b targetname Which specifies the name @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacons" need to have to make the DistanceMultiTrigger react to them if it is in <em>beacon-mode</em> (the beaconMode is not <em>off</em>).
    5773
    58         A simple DistanceMultiTrigger would look like this:
     74        A simple DistanceMultiTrigger could look like this:
    5975        @code
    6076        <DistanceMultiTrigger position="0,0,0" switch="true" target="Pawn" distance="20" />
     
    6379        An implementation that only reacts to objects with a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" attached would look like this:
    6480        @code
    65         <DistanceMultiTrigger position="0,0,0" target="DistanceMultiTrigger" targetname="beacon1" distance="30" />
     81        <DistanceMultiTrigger position="0,0,0" target="Pawn" beaconMode="identify" targetname="beacon1" distance="30" />
    6682        @endcode
    6783        This particular DistanceMultiTrigger would only react if an object was in range, that had a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon" with the name <em>beacon1</em> attached.
    6884
    6985    @see MultiTrigger
    70         For more information on MultiTriggers.
     86        For more information on @ref orxonox::MultiTrigger "MultiTriggers".
    7187
    7288    @author
     
    7995
    8096        public:
    81             DistanceMultiTrigger(BaseObject* creator); //!< Default Constructor. Registers the object and initializes default values.
    82             virtual ~DistanceMultiTrigger(); //!< Destructor.
     97            DistanceMultiTrigger(BaseObject* creator); // Default Constructor. Registers the object and initializes default values.
     98            virtual ~DistanceMultiTrigger(); // Destructor.
    8399
    84             void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a DistanceMultiTrigger object through XML.
    85 
    86             void setTargetName(const std::string& targetname); //!< Set the target name of DistanceTriggerBeacons that triggers this DistanceMultiTrigger.
    87             /**
    88             @brief Get the target name of the DistanceTriggerbeacon, that triggers this DistanceMultiTrigger.
    89             @return Returns the target name as a string.
    90             */
    91             inline const std::string& getTargetName(void)
    92                 { return this->targetName_; }
    93 
     100            void XMLPort(Element& xmlelement, XMLPort::Mode mode); // Method for creating a DistanceMultiTrigger object through XML.
     101           
    94102            /**
    95103            @brief Set the distance at which the DistanceMultiTrigger triggers.
     
    104112            inline float getDistance() const
    105113                { return this->distance_; }
     114           
     115            void setBeaconModeDirect(distanceMultiTriggerBeaconMode::Value mode); // Set the beacon mode.
     116            /**
     117            @brief Get the beacon mode.
     118            @return Returns the mode as an enum.
     119            */
     120            inline distanceMultiTriggerBeaconMode::Value getBeaconModeDirect(void) const
     121                { return this->beaconMode_; }
     122            void setBeaconMode(const std::string& mode); // Set the beacon mode.
     123            const std::string& getBeaconMode(void) const; // Get the beacon mode.
     124
     125            /**
     126            @brief Set the target name of DistanceTriggerBeacons that triggers this DistanceMultiTrigger.
     127            @param targetname The name of the DistanceTriggerBeacon as a string.
     128            */
     129            inline void setTargetName(const std::string& targetname)
     130                { this->targetName_ = targetname; }
     131            /**
     132            @brief Get the target name of the DistanceTriggerbeacon, that triggers this DistanceMultiTrigger.
     133            @return Returns the target name as a string.
     134            */
     135            inline const std::string& getTargetName(void) const
     136                { return this->targetName_; }
    106137
    107138        protected:
    108             virtual std::queue<MultiTriggerState*>* letTrigger(void); //!< This method is called by the MultiTrigger to get information about new trigger events that need to be looked at.
     139            virtual std::queue<MultiTriggerState*>* letTrigger(void); // This method is called by the MultiTrigger to get information about new trigger events that need to be looked at.
    109140
    110             bool addToRange(WorldEntity* entity); //!< Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger.
    111             bool removeFromRange(WorldEntity* entity); //!< Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.
     141            bool addToRange(WorldEntity* entity); // Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger.
     142            bool removeFromRange(WorldEntity* entity); // Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.
    112143
    113144        private:
     145            //! Strings for the beacon modes.
     146            static const std::string beaconModeOff_s;
     147            static const std::string beaconModeIdentify_s;
     148            static const std::string beaconModeExlcude_s;
     149           
    114150            float distance_; //!< The distance at which the DistanceMultiTrigger triggers.
     151
     152            distanceMultiTriggerBeaconMode::Value beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in.
    115153            std::string targetName_; //!< The target name, used in <em>single-target</em> mode.
    116             bool singleTargetMode_; //!< To indicate whe the MultiDistanceTrigger is in <em>single-target</em> mode.
     154            ClassTreeMask* beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
    117155
    118156            std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
Note: See TracChangeset for help on using the changeset viewer.