Changeset 7493 for code/trunk/src/modules/pickup/PickupSpawner.cc
- Timestamp:
- Sep 27, 2010, 7:53:30 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/PickupSpawner.cc
r7401 r7493 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "core/GameMode.h" 37 38 #include "core/Template.h" 38 39 #include "core/XMLPort.h" … … 94 95 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier()); 95 96 this->attach(representation->getSpawnerRepresentation(this)); 97 this->setActive(true); //TODO: Needed? 96 98 } 97 99 } … … 146 148 { 147 149 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier()); 148 representation->setVisible(this->isActive());149 150 this->attach(representation->getSpawnerRepresentation(this)); 150 this->setActive(true); 151 this->setActive(true); //TODO: Needed? 151 152 } 152 153 } … … 160 161 SUPER(PickupSpawner, changedActivity); 161 162 162 this->setVisible(this->isActive()); 163 if(GameMode::isMaster()) 164 this->setVisible(this->isActive()); 163 165 } 164 166 … … 169 171 Time since last tick. 170 172 */ 171 //TODO: Replace with collisions .173 //TODO: Replace with collisions? 172 174 void PickupSpawner::tick(float dt) 173 175 { 174 176 SUPER(PickupSpawner, tick, dt); 175 177 176 // !If the PickupSpawner is active.177 if (this->isActive())178 // If the PickupSpawner is active. 179 if(GameMode::isMaster() && this->isActive()) 178 180 { 179 181 SmartPtr<PickupSpawner> temp = this; //Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup) 180 182 181 // !Iterate trough all Pawns.183 // Iterate trough all Pawns. 182 184 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 183 185 { 184 186 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); 185 187 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it); 186 // !If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.188 // If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance. 187 189 if (distance.length() < this->triggerDistance_ && carrier != NULL && carrier->isTarget(this->pickup_)) 188 190 { … … 214 216 { 215 217 if(this->spawnsRemaining_ != INF) 216 {217 218 this->spawnsRemaining_--; 218 } 219 219 220 if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0) 220 221 { … … 283 284 void PickupSpawner::trigger(Pawn* pawn) 284 285 { 285 if (this->isActive()) //!<Checks whether PickupSpawner is active.286 if(this->isActive()) // Checks whether PickupSpawner is active. 286 287 { 287 288 COUT(4) << "PickupSpawner (&" << this << ") triggered and active." << std::endl; … … 303 304 Pickupable* pickup = this->getPickup(); 304 305 305 if(target != NULL && pickup != NULL) 306 { 307 if(pickup->pickup(target)) 308 this->decrementSpawnsRemaining(); 309 else 310 { 311 this->selfDestruct_ = true; 312 pickup->destroy(); 313 } 314 } 315 else 316 { 317 if(target == NULL) 318 COUT(1) << "PickupSpawner (&" << this << "): Pickupable has no target." << std::endl; 319 320 if(pickup == NULL) 321 COUT(1) << "PickupSpawner (&" << this << "): getPickup produced an error, no Pickupable created." << std::endl; 322 else 323 { 324 this->selfDestruct_ = true; 325 pickup->destroy(); 326 } 327 } 306 assert(pickup); 307 assert(target); 308 assert(pickup->pickup(target)); 309 310 this->decrementSpawnsRemaining(); 328 311 } 329 312 }
Note: See TracChangeset
for help on using the changeset viewer.