- Timestamp:
- Aug 31, 2010, 11:31:37 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
r7163 r7301 48 48 /** 49 49 @brief 50 The DistanceMultiTrigger is a trigger 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 DistanceTriggerBeacon (just attaching it) to the objects that can trigger this DistanceMultiTrigger and specify the name of the DistanceTriggerBeacon with the parameter targetname and only objects that hav a DistanceTriggerBeacon with that name attached will trigger the DistanceMultiTrigger. 50 The DistanceMultiTrigger is a trigger 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 DistanceTriggerBeacon (just attaching it) to the objects that can trigger this DistanceMultiTrigger and specify the name of the DistanceTriggerBeacon with the parameter targetname and only objects that have a DistanceTriggerBeacon with that name attached will trigger the DistanceMultiTrigger. 51 Parameters are (additional to the ones of MultiTrigger): 52 'distance', which specifies the maximum distance at which the DistanceMultiTrigger still triggers. Default is 100. 53 'targetname', which, if not left blank, causes the DistancMultiTrigger to be in single-target mode, meaning, that it only reacts to objects that have a DistanceTriggerBeacon (therefore the target has to be set to DistanceTriggerBeacon for it to work), with the name specified by targetname, attached. 54 55 A simple DistanceMultiTrigger would look like this: 56 @code 57 <DistanceMultiTrigger position="0,0,0" switch="true" target="Pawn" distance="20" /> 58 @endcode 59 60 An implementation that only reacts to objects with a DistanceTriggerBeacon attached would look like this: 61 @code 62 <DistanceMultiTrigger position="0,0,0" target="DistanceMultiTrigger" targetname="beacon1" distance="30" /> 63 @endcode 64 This particular DistanceMultiTrigger would only react if an object was in range, that had a DistanceTriggerBeacon with the name 'beacon1' attached. 51 65 @see MultiTrigger.h 52 66 For more information on MultiTriggers. … … 59 73 public: 60 74 DistanceMultiTrigger(BaseObject* creator); //!< Default Constructor. Registers the object and initializes default values. 61 ~DistanceMultiTrigger(); //!< Destructor.75 virtual ~DistanceMultiTrigger(); //!< Destructor. 62 76 63 77 void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a DistanceMultiTrigger object through XML. 64 78 65 /** 66 @brief Set the target name of DistanceTriggerBeacons that triggers this DistanceMultiTrigger. 67 @param targename The name of the DistanceTriggerBeacon as a string. 68 */ 69 inline void setTargetName(const std::string& targetname) 70 { if(targetname.compare(BLANKSTRING) != 0) this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; } 79 void setTargetName(const std::string& targetname); //!< Set the target name of DistanceTriggerBeacons that triggers this DistanceMultiTrigger. 71 80 /** 72 81 @brief Get the target name of the DistanceTriggerbeacon, that triggers this DistanceMultiTrigger. … … 92 101 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. 93 102 94 /** 95 @brief Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger. 96 @param entity A pointer to the entity. 97 @return Returns true if successful, false if not. 98 */ 99 inline bool addToRange(WorldEntity* entity) 100 { std::pair<std::map<WorldEntity*, WeakPtr<WorldEntity>* >::iterator, bool> pair = this->range_.insert(std::pair<WorldEntity*, WeakPtr<WorldEntity>* >(entity, new WeakPtr<WorldEntity>(entity))); return pair.second; } 101 /** 102 @brief Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger. 103 @param entity A pointer ot the entity. 104 @return Returns true if successful. 105 */ 106 inline bool removeFromRange(WorldEntity* entity) 107 { WeakPtr<WorldEntity>* weakptr = this->range_.find(entity)->second; bool erased = this->range_.erase(entity) > 0; if(erased) delete weakptr; return erased; } 103 bool addToRange(WorldEntity* entity); //!< Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger. 104 bool removeFromRange(WorldEntity* entity); //!< Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger. 108 105 109 106 private:
Note: See TracChangeset
for help on using the changeset viewer.