Changeset 7456 for code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
- Timestamp:
- Sep 15, 2010, 7:29:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
r7401 r7456 28 28 29 29 /** 30 @file 30 @file QuestEffectBeacon.cc 31 31 @brief Implementation of the QuestEffectBeacon class. 32 32 */ … … 37 37 #include "core/XMLPort.h" 38 38 #include "core/EventIncludes.h" 39 40 #include "interfaces/PlayerTrigger.h" 39 41 #include "worldentities/pawns/Pawn.h" 40 #include "interfaces/PlayerTrigger.h" 42 41 43 #include "objects/triggers/MultiTriggerContainer.h" 42 44 #include "QuestEffect.h" … … 50 52 Constructor. Registers the object and initializes defaults. 51 53 */ 54 //TODO: Make just BaseObject? 52 55 QuestEffectBeacon::QuestEffectBeacon(BaseObject* creator) : StaticEntity(creator) 53 56 { … … 99 102 Returns true if successfully executed, false if not. 100 103 */ 104 //TODO: Eliminate MultiTriggerContainer stuff, since they are now PlayerTriggers as well. 101 105 bool QuestEffectBeacon::execute(bool bTriggered, BaseObject* trigger) 102 106 { … … 105 109 return false; 106 110 } 107 if(!(this->isActive())) // !<If the QuestEffectBeacon is inactive it cannot be executed.111 if(!(this->isActive())) // If the QuestEffectBeacon is inactive it cannot be executed. 108 112 { 109 113 COUT(4) << "The QuestEffectBeacon is inactive." << std::endl; … … 115 119 Pawn* pawn = NULL; 116 120 117 // !If the trigger is neither a Playertrigger nor a MultiTrigger (i.e. a MultitriggerContainer) we can do anything with it.121 // If the trigger is neither a Playertrigger nor a MultiTrigger (i.e. a MultitriggerContainer) we can do anything with it. 118 122 if(pTrigger == NULL && mTrigger == NULL) 119 123 return false; … … 122 126 if(pTrigger != NULL) 123 127 { 124 if(!pTrigger->isForPlayer()) // !<The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.128 if(!pTrigger->isForPlayer()) // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one. 125 129 return false; 126 130 else … … 140 144 } 141 145 142 // !Extract the PlayerInfo from the Pawn.146 // Extract the PlayerInfo from the Pawn. 143 147 PlayerInfo* player = pawn->getPlayer(); 144 148 … … 151 155 COUT(4) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl; 152 156 153 bool check = QuestEffect::invokeEffects(player, this->effects_); // !<Invoke the QuestEffects on the PlayerInfo.157 bool check = QuestEffect::invokeEffects(player, this->effects_); // Invoke the QuestEffects on the PlayerInfo. 154 158 if(check) 155 159 { 156 this->decrementTimes(); // !<Decrement the number of times the beacon can be used.160 this->decrementTimes(); // Decrement the number of times the beacon can be used. 157 161 return true; 158 162 } … … 171 175 bool QuestEffectBeacon::setActive(bool activate) 172 176 { 173 if(this->getTimes() == 0 && activate) //!< A QuestEffectBeacon that can be executed only 0 times is always inactive. 174 { 175 return false; 176 } 177 if(this->getTimes() == 0 && activate) // A QuestEffectBeacon that can be executed only 0 times is always inactive. 178 return false; 177 179 178 180 if(activate) 179 181 { 180 this->status_ = QuestEffectBeaconStatus::Active;181 return true;182 this->status_ = QuestEffectBeaconStatus::Active; 183 return true; 182 184 } 183 185 … … 194 196 bool QuestEffectBeacon::decrementTimes(void) 195 197 { 196 if(!(this->isActive())) //!< The QuestEffectBeacon mus be active to decrement the number of times it can be executed. 197 { 198 return false; 199 } 200 if(this->getTimes() == INFINITE_TIME) //!< If times is infinity the QuestEffectBeacon can be executed an infinite number fo times. 201 { 198 if(!(this->isActive())) // The QuestEffectBeacon mus be active to decrement the number of times it can be executed. 199 return false; 200 201 if(this->getTimes() == INFINITE_TIME) // If times is infinity the QuestEffectBeacon can be executed an infinite number fo times. 202 202 return true; 203 } 204 205 this->times_ = this->times_ - 1; //!< Decrement number of times the QuestEffectBeacon can be executed. 206 if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0. 207 { 203 204 this->times_ = this->times_ - 1; // Decrement number of times the QuestEffectBeacon can be executed. 205 if(this->getTimes() == 0) // Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0. 208 206 this->status_ = QuestEffectBeaconStatus::Inactive; 209 }210 207 211 208 return true; … … 225 222 { 226 223 if(n < 0 && n != INFINITE_TIME) 227 { 228 return false; 229 } 224 return false; 230 225 231 226 this->times_ = n; … … 243 238 bool QuestEffectBeacon::addEffect(QuestEffect* effect) 244 239 { 245 if(effect == NULL) //!< NULL-pointers are not well liked here... 240 //TODO: Replace with assert. 241 if(effect == NULL) // NULL-pointers are not well liked here... 246 242 { 247 243 COUT(2) << "A NULL-QuestEffect was trying to be added" << std::endl; … … 269 265 { 270 266 if(i == 0) 271 {272 267 return *effect; 273 } 268 274 269 i--; 275 270 }
Note: See TracChangeset
for help on using the changeset viewer.