Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 16, 2010, 2:18:45 PM (14 years ago)
Author:
dafrick
Message:

Resolving some more TODO's.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/pickup/PickupSpawner.cc

    r7548 r7549  
    108108    {
    109109        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;
    111111        this->maxSpawnedItems_ = INF;
    112112        this->spawnsRemaining_ = INF;
     
    151151            PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
    152152            this->attach(representation->getSpawnerRepresentation(this));
    153             this->setActive(true); //TODO: Needed?
     153            this->setActive(true);
    154154        }
    155155    }
     
    183183            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)
    184184
     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
    185194            // Iterate trough all Pawns.
    186             for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
     195            for(ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    187196            {
    188197                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
    189198                PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it);
    190                 // If a Pawn, 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())
    192201                {
    193202                    if(carrier->isTarget(this->pickup_))
     
    292301
    293302            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.
    300306            if(!carrier->isTarget(this->pickup_))
    301307            {
     
    307313            Pickupable* pickup = this->getPickup();
    308314
     315            this->block(carrier);
     316
    309317            assert(pickup);
    310318            assert(target);
Note: See TracChangeset for help on using the changeset viewer.