Changeset 2530 for code/branches/bugger/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
- Timestamp:
- Dec 23, 2008, 10:40:38 PM (16 years ago)
- Location:
- code/branches/bugger
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/bugger
- Property svn:mergeinfo changed
/code/branches/questsystem2 (added) merged: 2109,2146,2159,2191,2193-2196,2205-2206,2208-2209,2221,2226,2228,2251,2258
- Property svn:mergeinfo changed
-
code/branches/bugger/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
- Property svn:mergeinfo changed
/code/branches/questsystem2/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc (added) merged: 2193,2196,2205-2206,2209,2221
r2171 r2530 35 35 #include "core/XMLPort.h" 36 36 37 #include "orxonox/objects/worldentities/ControllableEntity.h" 38 37 39 namespace orxonox 38 40 { 39 41 CreateFactory(DistanceTrigger); 40 42 41 DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator)43 DistanceTrigger::DistanceTrigger(BaseObject* creator) : PlayerTrigger(creator) 42 44 { 43 45 RegisterObject(DistanceTrigger); … … 45 47 this->distance_ = 100; 46 48 this->targetMask_.exclude(Class(BaseObject)); 49 this->setForPlayer(false); //!< Normally hasn't just ControllableEntities as targets. 47 50 } 48 51 … … 83 86 { 84 87 Identifier* targetId = ClassByString(targets); 88 89 //! Checks whether the target is (or is derived from) a ControllableEntity. 90 Identifier* controllableEntityId = Class(ControllableEntity); 91 if(targetId->isA(controllableEntityId)) 92 { 93 this->setForPlayer(true); 94 } 95 85 96 if (!targetId) 86 97 { … … 117 128 Vector3 distanceVec = entity->getWorldPosition() - this->getWorldPosition(); 118 129 if (distanceVec.length() < this->distance_) 130 { 131 132 //! If the target is a player (resp. is a, or is derived from a, ControllableEntity) the triggeringPlayer is set to the target entity. 133 if(this->isForPlayer()) 134 { 135 ControllableEntity* player = dynamic_cast<ControllableEntity*>(entity); 136 this->setTriggeringPlayer(player); 137 } 138 119 139 return true; 140 } 120 141 } 121 142 return false; 122 123 143 } 124 144 … … 126 146 { 127 147 if (Trigger::isTriggered(mode)) 148 { 128 149 return checkDistance(); 150 } 129 151 else 130 152 return false; - Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.