Changeset 8706 for code/trunk/src/modules/objects/triggers
- Timestamp:
- Jun 14, 2011, 8:53:28 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
r8213 r8706 53 53 Default Constructor. Registers the object and initializes default values. 54 54 */ 55 DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator) , beaconMask_(NULL)55 DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator) 56 56 { 57 57 RegisterObject(DistanceMultiTrigger); … … 60 60 this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::off); 61 61 this->targetName_ = ""; 62 this->beaconMask_.exclude(Class(BaseObject)); 63 this->beaconMask_.include(Class(DistanceTriggerBeacon)); 62 64 } 63 65 … … 68 70 DistanceMultiTrigger::~DistanceMultiTrigger() 69 71 { 70 if(this->beaconMask_ != NULL) 71 delete this->beaconMask_; 72 72 73 } 73 74 … … 135 136 // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons. 136 137 if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify) 137 targetMask = *this->beaconMask_;138 targetMask = this->beaconMask_; 138 139 139 140 // Iterate through all objects that are targets of the DistanceMultiTrigger. … … 207 208 { 208 209 this->beaconMode_ = mode; 209 if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify && this->beaconMask_ == NULL)210 {211 this->beaconMask_ = new ClassTreeMask();212 this->beaconMask_->exclude(Class(BaseObject));213 this->beaconMask_->include(Class(DistanceTriggerBeacon));214 }215 210 } 216 211 -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
r8213 r8706 152 152 distanceMultiTriggerBeaconMode::Value beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in. 153 153 std::string targetName_; //!< The target name, used in <em>single-target</em> mode. 154 ClassTreeMask *beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.154 ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons. 155 155 156 156 std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger. -
code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
r8213 r8706 57 57 The creator of this trigger. 58 58 */ 59 DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator) , beaconMask_(NULL)59 DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator) 60 60 { 61 61 RegisterObject(DistanceTrigger); … … 64 64 this->targetMask_.exclude(Class(BaseObject)); 65 65 this->targetName_ = ""; 66 this->beaconMask_.exclude(Class(BaseObject)); 67 this->beaconMask_.include(Class(DistanceTriggerBeacon)); 66 68 } 67 69 … … 72 74 DistanceTrigger::~DistanceTrigger() 73 75 { 74 // Delete the beacon mask if it exists. 75 if(this->beaconMask_ != NULL) 76 delete this->beaconMask_; 76 77 77 } 78 78 … … 159 159 // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons. 160 160 if(this->beaconMode_ == distanceTriggerBeaconMode::identify) 161 targetMask = *this->beaconMask_;161 targetMask = this->beaconMask_; 162 162 163 163 // Iterate through all objects that are targets of the DistanceTrigger. … … 205 205 entity = entity->getParent(); 206 206 207 Pawn* player = orxonox_cast<Pawn*>(entity); 208 this->setTriggeringPlayer(player); 207 Pawn* pawn = orxonox_cast<Pawn*>(entity); 208 if(pawn != NULL) 209 this->setTriggeringPawn(pawn); 210 else 211 CCOUT(2) << "Pawn was NULL." << endl; 209 212 } 210 213 … … 228 231 { 229 232 this->beaconMode_ = mode; 230 if(this->beaconMode_ == distanceTriggerBeaconMode::identify && this->beaconMask_ == NULL)231 {232 this->beaconMask_ = new ClassTreeMask();233 this->beaconMask_->exclude(Class(BaseObject));234 this->beaconMask_->include(Class(DistanceTriggerBeacon));235 }236 233 } 237 234 … … 280 277 Check whether the DistanceTrigger is triggered. 281 278 It is triggered if it is triggered according only to its mode (i.e. its sub-triggers) and if a target is in range. 282 @param 279 @param mode 280 The mode for which it is tested, whether the DistanceTrigger is triggered. 281 @return 283 282 Returns true if it is triggered ,false if not. 284 283 */ -
code/trunk/src/modules/objects/triggers/DistanceTrigger.h
r8213 r8706 71 71 - @b target Which specifies the class of objects that can trigger the DistanceTrigger. Default is <code>"Pawn"</code>. 72 72 - @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>. 73 - @b targetname Which specifies the name @ref or oxnox::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>).73 - @b targetname Which specifies the name @ref orxonox::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>). 74 74 75 75 A simple DistanceTrigger could look like this: … … 162 162 distanceTriggerBeaconMode::Value beaconMode_; //!< The beacon mode. 163 163 std::string targetName_; //!< The name a DistanceTriggerBeacon needs to have to make the DistanceTrigger react to it if in beacon-mode. 164 ClassTreeMask *beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.164 ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons. 165 165 166 166 WeakPtr<WorldEntity> cache_; //!< Caches the entity that triggered the DistanceTrigger last. -
code/trunk/src/modules/objects/triggers/EventTrigger.h
r8213 r8706 60 60 61 61 @see Trigger 62 For more information on @ref or oxnox::Trigger "Triggers".62 For more information on @ref orxonox::Trigger "Triggers". 63 63 64 64 @author -
code/trunk/src/modules/objects/triggers/MultiTrigger.cc
r8213 r8706 63 63 this->bMultiTrigger_ = true; 64 64 65 this->setSyncMode( 0x0);65 this->setSyncMode(ObjectDirection::None); 66 66 } 67 67 … … 198 198 if(bActive ^ this->isActive(state->originator)) 199 199 { 200 201 200 bool bFire = true; 202 201 … … 312 311 313 312 // We only want WorldEntities 314 //TODO: Really?315 313 ClassTreeMask WEMask; 316 314 WEMask.include(Class(WorldEntity)); -
code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc
r7601 r8706 73 73 { 74 74 this->setForPlayer(true); 75 this->setTriggeringP layer(pawn);75 this->setTriggeringPawn(pawn); 76 76 } 77 77 } -
code/trunk/src/modules/objects/triggers/Trigger.cc
r8213 r8706 76 76 } 77 77 78 this->setSyncMode( 0x0);78 this->setSyncMode(ObjectDirection::None); 79 79 } 80 80 -
code/trunk/src/modules/objects/triggers/TriggerBase.cc
r7652 r8706 71 71 this->bMultiTrigger_ = false; 72 72 73 this->setSyncMode( 0x0);73 this->setSyncMode(ObjectDirection::None); 74 74 } 75 75 -
code/trunk/src/modules/objects/triggers/TriggerBase.h
r8213 r8706 133 133 inline int getActivations(void) const 134 134 { return this->remainingActivations_; } 135 /** 136 @brief Check whether the trigger has still at least one remaining activation. 137 @return Returns true if the trigger has remaining activations (i.e. the number of remaining activations is not zero). 138 */ 139 inline bool hasRemainingActivations(void) const 140 { return this->remainingActivations_ > 0 || this->remainingActivations_ == INF_s; } 135 141 136 142 /**
Note: See TracChangeset
for help on using the changeset viewer.