Changeset 7549 for code/trunk/src/modules/pickup/PickupSpawner.cc
- Timestamp:
- Oct 16, 2010, 2:18:45 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/PickupSpawner.cc
r7548 r7549 108 108 { 109 109 this->triggerDistance_ = 10; 110 this->respawnTime_ = 0; //TODO: Smart? Shouldn't we have a better mechanism to prevent unwanted multiple pickups?110 this->respawnTime_ = 5.0f; 111 111 this->maxSpawnedItems_ = INF; 112 112 this->spawnsRemaining_ = INF; … … 151 151 PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier()); 152 152 this->attach(representation->getSpawnerRepresentation(this)); 153 this->setActive(true); //TODO: Needed?153 this->setActive(true); 154 154 } 155 155 } … … 183 183 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) 184 184 185 // Remove PickupCarriers from the blocked list if they have exceeded their time. 186 for(std::map<PickupCarrier*, std::time_t>::iterator it = this->blocked_.begin(); it != this->blocked_.end(); ) 187 { 188 std::map<PickupCarrier*, std::time_t>::iterator temp = it; 189 it++; 190 if(temp->second < std::time(0)) 191 this->blocked_.erase(temp); 192 } 193 185 194 // Iterate trough all Pawns. 186 for 195 for(ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) 187 196 { 188 197 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); 189 198 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it); 190 // If a P awn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.191 if (distance.length() < this->triggerDistance_ && carrier != NULL)199 // If a PickupCarrier, that fits the target-range of the Pickupable spawned by this PickupSpawnder, is in trigger-distance and the carrier is not blocked. 200 if(distance.length() < this->triggerDistance_ && carrier != NULL && this->blocked_.find(carrier) == this->blocked_.end()) 192 201 { 193 202 if(carrier->isTarget(this->pickup_)) … … 292 301 293 302 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn); 294 if(carrier == NULL) 295 { 296 COUT(1) << "This is bad. Pawn isn't PickupCarrier." << std::endl; 297 return; 298 } 299 303 assert(carrier); 304 305 // If the Pawn isn't a target of the Pickupable. 300 306 if(!carrier->isTarget(this->pickup_)) 301 307 { … … 307 313 Pickupable* pickup = this->getPickup(); 308 314 315 this->block(carrier); 316 309 317 assert(pickup); 310 318 assert(target);
Note: See TracChangeset
for help on using the changeset viewer.