Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 5, 2010, 6:26:54 PM (14 years ago)
Author:
dafrick
Message:

Additional documentation, code niceifying and potential bug fixing. Also: Renamed DroppedItem to DroppedPickup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup3/src/modules/pickup/PickupCollection.cc

    r6466 r6475  
    3838#include "core/XMLPort.h"
    3939#include "interfaces/PickupCarrier.h"
     40#include "DroppedPickup.h"
     41
     42#include "PickupCollectionIdentifier.h"
    4043
    4144namespace orxonox
     
    4952    {
    5053        RegisterObject(PickupCollection);
     54       
     55        this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier();
    5156    }
    5257   
     
    6065        for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    6166        {
    62             delete *it;
     67            (*it)->destroy();
    6368        }
    6469    }
     
    8085    void PickupCollection::initializeIdentifier(void)
    8186    {
    82         this->pickupCollectionIdentifier_.addClass(this->getIdentifier());
     87        this->pickupCollectionIdentifier_->addClass(this->getIdentifier());
    8388       
    8489        for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    8590        {
    86             this->pickupCollectionIdentifier_.addPickup((*it)->getPickupIdentifier());
     91            this->pickupCollectionIdentifier_->addPickup((*it)->getPickupIdentifier());
    8792        }
     93    }
     94   
     95    /**
     96    @brief
     97        Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
     98        This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
     99        DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position);
     100    @param position
     101        The position at which the PickupSpawner should be placed.
     102    @return
     103        Returns true if a spawner was created, false if not.
     104    */
     105    bool PickupCollection::createSpawner(const Vector3& position)
     106    {
     107        DroppedPickup::DroppedPickup(this, this, position);
     108        return true;
    88109    }
    89110   
     
    159180    }
    160181   
     182    const PickupIdentifier* PickupCollection::getPickupIdentifier(void)
     183    {
     184        return this->pickupCollectionIdentifier_;
     185    }
     186   
    161187}
Note: See TracChangeset for help on using the changeset viewer.