Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 8, 2010, 8:53:52 PM (14 years ago)
Author:
dafrick
Message:

Significant structural changes to the pickup module. Lots of bugs found and fixed.
Introduced a new class CollectiblePickup (which is now the only kind a PickupCollection can consist of) to solve some issues cleanly.
MetaPickup received additional functionality. It can now also be set to either destroy all the pickups of a PickupCarrier or destroy the PickupCarrier itself. (This was done mainly for testing purposes)
I've done some extensive testing on the pickups, so they should really work now.

Location:
code/branches/presentation3/src/modules/pickup
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/src/modules/pickup/CMakeLists.txt

    r7135 r7162  
    11SET_SOURCE_FILES(PICKUP_SRC_FILES
     2  CollectiblePickup.cc
    23  DroppedPickup.cc
    34  Pickup.cc
  • code/branches/presentation3/src/modules/pickup/Pickup.cc

    r7129 r7162  
    194194
    195195        //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.
    196         if(this->getCarrier() != NULL && this->isPickedUp() && this->isImmediate())
     196        if(this->isPickedUp() && this->isImmediate())
    197197        {
    198198            this->setUsed(true);
  • code/branches/presentation3/src/modules/pickup/Pickup.h

    r7129 r7162  
    4040#include "core/XMLPort.h"
    4141
    42 #include "interfaces/Pickupable.h"
     42#include "CollectiblePickup.h"
    4343
    4444#include "tools/Timer.h"
     
    7474        Damian 'Mozork' Frick
    7575    */
    76     class _PickupExport Pickup : public Pickupable, public BaseObject
     76    class _PickupExport Pickup : public CollectiblePickup, public BaseObject
    7777    {
    7878
  • code/branches/presentation3/src/modules/pickup/PickupCollection.cc

    r7127 r7162  
    3535#include "core/XMLPort.h"
    3636#include "interfaces/PickupCarrier.h"
     37#include "CollectiblePickup.h"
    3738#include "DroppedPickup.h"
    3839#include "PickupCollectionIdentifier.h"
     
    5455
    5556        this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier(this);
     57        this->usedCounter_ = 0;
     58        this->pickedUpCounter_ = 0;
     59        this->disabledCounter_ = 0;
     60        this->processingUsed_ = false;
     61        this->processingPickedUp_ = false;
    5662    }
    5763
     
    6268    PickupCollection::~PickupCollection()
    6369    {
    64         //! Destroy all Pickupables constructing this PickupCollection.
    65         for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    66         {
    67             if((*it).get() != NULL)
    68                 (*it).get()->destroy();
    69         }
     70        // Destroy all Pickupables constructing this PickupCollection.
     71        for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
     72        {
     73            (*it)->removeFromCollection();
     74            (*it)->destroy();
     75        }
     76        this->pickups_.clear();
    7077    }
    7178
     
    7885        SUPER(PickupCollection, XMLPort, xmlelement, mode);
    7986
    80         XMLPortObject(PickupCollection, Pickupable, "pickupables", addPickupable, getPickupable, xmlelement, mode);
     87        XMLPortObject(PickupCollection, CollectiblePickup, "pickupables", addPickupable, getPickupable, xmlelement, mode);
    8188
    8289        this->initializeIdentifier();
     
    8996    void PickupCollection::initializeIdentifier(void)
    9097    {
    91         for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    92         {
    93             this->pickupCollectionIdentifier_->addPickup((*it).get()->getPickupIdentifier());
     98        for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
     99        {
     100            this->pickupCollectionIdentifier_->addPickup((*it)->getPickupIdentifier());
    94101        }
    95102    }
     
    104111        SUPER(PickupCollection, changedUsed);
    105112
    106         //! Change used for all Pickupables this PickupCollection consists of.
    107         for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    108         {
    109             (*it).get()->setUsed(this->isUsed());
    110         }
     113        this->processingUsed_ = true;
     114        // Change used for all Pickupables this PickupCollection consists of.
     115        for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
     116        {
     117            (*it)->setUsed(this->isUsed());
     118        }
     119        this->processingUsed_ = false;
     120
     121        this->changedUsedAction();
     122    }
     123
     124    /**
     125    @brief
     126        Helper method.
     127        Checks whether due to changes in the used status of the pickups of this PickupCollection the used status of this PickupCollection has to change as well.
     128    */
     129    void PickupCollection::changedUsedAction(void)
     130    {
     131        if(this->processingUsed_)
     132            return;
     133
     134        // If all the pickups are not in use but the PickupCollection is.
     135        if(this->usedCounter_ == 0 && this->isUsed())
     136            this->setUsed(false);
     137
     138        // If all the enabled pickups are in use but the PickupCollection is not.
     139        if(this->usedCounter_ != 0 && this->usedCounter_ == this->pickups_.size()-this->disabledCounter_ && !this->isUsed())
     140            this->setUsed(true);
    111141    }
    112142
     
    120150        SUPER(PickupCollection, changedCarrier);
    121151
    122         //! Change the PickupCarrier for all Pickupables this PickupCollection consists of.
    123         for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    124         {
    125             (*it).get()->setCarrier(this->getCarrier()->getTarget(*it), true);
     152        // Change the PickupCarrier for all Pickupables this PickupCollection consists of.
     153        for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
     154        {
     155            if(this->getCarrier() == NULL)
     156                (*it)->setCarrier(NULL);
     157            else
     158                (*it)->setCarrier(this->getCarrier()->getTarget(*it));
    126159        }
    127160    }
     
    136169        SUPER(PickupCollection, changedPickedUp);
    137170
    138         //! Change the pickedUp status for all Pickupables this PickupCollection consists of.
    139         for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    140         {
    141             (*it).get()->setPickedUp(this->isPickedUp());
    142         }
     171        this->processingPickedUp_ = true;
     172        // Change the pickedUp status for all Pickupables this PickupCollection consists of.
     173        for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
     174        {
     175            (*it)->setPickedUp(this->isPickedUp());
     176        }
     177        this->processingPickedUp_ = false;
     178
     179        this->changedPickedUpAction();
     180    }
     181
     182    /**
     183    @brief
     184        Helper method.
     185        Checks whether due to changes in the picked up status of the pickups of this PickupCollection the picked up status of this PickupCollection has to change as well.
     186    */
     187    void PickupCollection::changedPickedUpAction(void)
     188    {
     189        if(this->processingPickedUp_)
     190            return;
     191
     192        // If at least all the enabled pickups of this PickupCollection are no longer picked up.
     193        if(this->pickedUpCounter_ <= this->disabledCounter_ && this->isPickedUp())
     194            this->Pickupable::destroy();
     195
     196        // If the PickupCollection is no longer picked up.
     197        if(!this->isPickedUp())
     198            this->pickedUpCounter_ = 0;
    143199    }
    144200
     
    158214
    159215        PickupCollection* pickup = dynamic_cast<PickupCollection*>(item);
    160         //! Clone all Pickupables this PickupCollection consist of.
    161         for(std::vector<WeakPtr<Pickupable> >::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    162         {
    163             Pickupable* newPickup = (*it).get()->clone();
    164             pickup->addPickupable(newPickup);
     216        // Clone all Pickupables this PickupCollection consist of.
     217        for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
     218        {
     219            Pickupable* newPickup = (*it)->clone();
     220            CollectiblePickup* collectible = static_cast<CollectiblePickup*>(newPickup);
     221            pickup->addPickupable(collectible);
    165222        }
    166223
     
    178235    bool PickupCollection::isTarget(PickupCarrier* carrier) const
    179236    {
    180         for(std::vector<WeakPtr<Pickupable> >::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
    181         {
    182             if(!carrier->isTarget((*it).get()))
     237        for(std::vector<CollectiblePickup*>::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
     238        {
     239            if(!carrier->isTarget(*it))
    183240                return false;
    184241        }
     
    207264        Returns true if successful,
    208265    */
    209     bool PickupCollection::addPickupable(Pickupable* pickup)
     266    bool PickupCollection::addPickupable(CollectiblePickup* pickup)
    210267    {
    211268        if(pickup == NULL)
    212269            return false;
    213270
    214         WeakPtr<Pickupable> ptr = pickup; //!< Create a weak pointer to be able to test in the constructor if the Pointer is still valid.
    215         this->pickups_.push_back(ptr);
     271        pickup->addToCollection(this);
     272        this->pickups_.push_back(pickup);
    216273        return true;
    217274    }
     
    227284    const Pickupable* PickupCollection::getPickupable(unsigned int index)
    228285    {
    229         return this->pickups_[index].get();
     286        return this->pickups_[index];
     287    }
     288
     289    /**
     290    @brief
     291        Informs the PickupCollection, that one of its pickups has changed its used status to the input value.
     292        This is used internally by the CollectiblePickup class.
     293    @param changed
     294        The value the used status has changed to.
     295    */
     296    void PickupCollection::pickupChangedUsed(bool changed)
     297    {
     298        if(changed)
     299            this->usedCounter_++;
     300        else
     301            this->usedCounter_--;
     302
     303        this->changedUsedAction();
     304    }
     305
     306    /**
     307    @brief
     308        Informs the PickupCollection, that one of its pickups has changed its picked up status to the input value.
     309        This is used internally by the CollectiblePickup class.
     310    @param changed
     311        The value the picked up status has changed to.
     312    */
     313    void PickupCollection::pickupChangedPickedUp(bool changed)
     314    {
     315        if(changed)
     316            this->pickedUpCounter_++;
     317        else
     318            this->pickedUpCounter_--;
     319
     320        this->changedPickedUpAction();
     321    }
     322
     323    /**
     324    @brief
     325        Informs the PickupCollection, that one of its pickups has been disabled.
     326        This is used internally by the CollectiblePickup class.
     327    */
     328    void PickupCollection::pickupDisabled(void)
     329    {
     330        this->disabledCounter_++;
    230331    }
    231332
  • code/branches/presentation3/src/modules/pickup/PickupCollection.h

    r7127 r7162  
    3737#include "PickupPrereqs.h"
    3838
    39 #include "interfaces/Pickupable.h"
    4039#include "core/BaseObject.h"
     40#include "CollectiblePickup.h"
    4141
    4242#include <list>
     
    4747    /**
    4848    @brief
    49         The PickupCollection combines different Pickupables to a coherent, single pickup and makes the seem (from the outside looking in) just as if they were just one Pickupable.
     49        The PickupCollection combines different Pickupables to a coherent, single pickup and makes them seem (from the outside looking in) just as if they were just one Pickupable.
    5050    @author
    5151        Damian 'Mozork' Frick
    5252    */
    53     class _PickupExport PickupCollection : public Pickupable, public BaseObject
     53    class _PickupExport PickupCollection : public CollectiblePickup, public BaseObject
    5454    {
    5555
    5656        public:
    57 
    5857            PickupCollection(BaseObject* creator); //!< Default Constructor.
    5958            virtual ~PickupCollection(); //!< Destructor.
     
    7170            virtual const PickupIdentifier* getPickupIdentifier(void); //!< Get the PickupIdentifier of this PickupCollection.
    7271
    73             bool addPickupable(Pickupable* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection.
     72            bool addPickupable(CollectiblePickup* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection.
    7473            const Pickupable* getPickupable(unsigned int index); //!< Get the Pickupable at the given index.
     74
     75            void pickupChangedUsed(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its used status to the input value.
     76            void pickupChangedPickedUp(bool changed); //!< Informs the PickupCollection, that one of its pickups has changed its picked up status to the input value.
     77            void pickupDisabled(void); //!< Informs the PickupCollection, that one of its pickups has been disabled.
    7578
    7679        protected:
     
    8285
    8386        private:
     87            void changedUsedAction(void); //!< Helper method.
     88            void changedPickedUpAction(void); //!< Helper method.
     89           
     90            std::vector<CollectiblePickup*> pickups_; //!< The list of the pointers of all the Pickupables this PickupCollection consists of. They are weak pointers to facilitate testing, whether the pointers are still valid.
    8491
    85             std::vector<WeakPtr<Pickupable> > pickups_; //!< The list of the pointers of all the Pickupables this PickupCollection consists of. They are weak pointers to facilitate testing, whether the pointers are still valid.
     92            unsigned int usedCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are in use.
     93            unsigned int pickedUpCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are picked up.
     94            unsigned int disabledCounter_; //!< Keeps track of the number of pickups of this PickupCollection, that are disabled.
     95
     96            bool processingUsed_; //!< Boolean to ensure, that the PickupCollection doesn't update its used status while its internal state is inconsistent.
     97            bool processingPickedUp_; //!< Boolean to ensure, that the PickupCollection doesn't update its picked upp status while its internal state is inconsistent.
    8698
    8799    };
  • code/branches/presentation3/src/modules/pickup/PickupCollectionIdentifier.cc

    r7129 r7162  
    6767    int PickupCollectionIdentifier::compare(const PickupIdentifier* identifier) const
    6868    {
    69         //! Slight un-niceity to cast the PickupIdentifier to a PickupCollectionIdentifier.
     69        // Slight un-niceity to cast the PickupIdentifier to a PickupCollectionIdentifier.
    7070        PickupIdentifier* temp = const_cast<PickupIdentifier*>(identifier);
    7171        const PickupCollectionIdentifier* collectionIdentifier = dynamic_cast<PickupCollectionIdentifier*>(temp);
    7272
    73         //! If the input PickupIdentifier 'identifier' is no PickupCollectionIdentifier then just the two PickupIdentifiers are compared.
     73        // If the input PickupIdentifier 'identifier' is no PickupCollectionIdentifier then just the two PickupIdentifiers are compared.
    7474        if(collectionIdentifier == NULL)
    7575        {
     
    7777        }
    7878
    79         //! If the number of Pickupables each of the two PickupCollectionIdentifiers contain differ, the one with less is considered smaller.
     79        // If the number of Pickupables each of the two PickupCollectionIdentifiers contain differ, the one with less is considered smaller.
    8080        if(this->identifiers_.size() != collectionIdentifier->identifiers_.size())
    8181            return this->identifiers_.size()-collectionIdentifier->identifiers_.size();
    8282
    83         //! Compare the Pickupables of the two PickupCollectionIdentifiers one after the other. the one with the first 'smaller' one is considered smaller.
     83        // Compare the Pickupables of the two PickupCollectionIdentifiers one after the other. the one with the first 'smaller' one is considered smaller.
    8484        std::set<const PickupIdentifier*, PickupIdentifierCompare>::const_iterator it2 = collectionIdentifier->identifiers_.begin();
    8585        for(std::set<const PickupIdentifier*, PickupIdentifierCompare>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); it++)
  • code/branches/presentation3/src/modules/pickup/PickupManager.cc

    r7150 r7162  
    4343#include "infos/PlayerInfo.h"
    4444#include "worldentities/pawns/Pawn.h"
     45#include "CollectiblePickup.h"
    4546#include "PickupRepresentation.h"
    4647
     
    6465        RegisterRootObject(PickupManager);
    6566
     67        //TODO: This doesn't work, yet.
    6668        if( GameMode::showsGraphics() )
    6769        {
     
    172174            for(std::set<Pickupable*>::iterator pickup = pickups.begin(); pickup != pickups.end(); pickup++)
    173175            {
    174                 this->pickupsList_.insert(std::pair<Pickupable*, WeakPtr<Pickupable> >(*pickup, WeakPtr<Pickupable>(*pickup)));
     176                CollectiblePickup* collectible = orxonox_cast<CollectiblePickup*>(*pickup);
     177                if(collectible == NULL || !collectible->isInCollection())
     178                    this->pickupsList_.insert(std::pair<Pickupable*, WeakPtr<Pickupable> >(*pickup, WeakPtr<Pickupable>(*pickup)));
    175179            }
    176180        }
  • code/branches/presentation3/src/modules/pickup/PickupPrereqs.h

    r7136 r7162  
    6666{
    6767
     68    class CollectiblePickup;
    6869    class DroppedPickup;
    6970    class Pickup;
  • code/branches/presentation3/src/modules/pickup/PickupRepresentation.h

    r7129 r7162  
    149149            std::string spawnerTemplate_; //!<  The name of the template of this PickupRepresentation.
    150150            StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation.
    151             std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory. TODO: Exact format and placement of image?
     151            std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory.
    152152
    153153            Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.
  • code/branches/presentation3/src/modules/pickup/PickupSpawner.cc

    r7150 r7162  
    107107        this->maxSpawnedItems_ = INF;
    108108        this->spawnsRemaining_ = INF;
     109        this->selfDestruct_ = false;
    109110    }
    110111
     
    115116    PickupSpawner::~PickupSpawner()
    116117    {
    117         if(this->pickup_ != NULL)
     118        if(this->selfDestruct_ && this->pickup_ != NULL)
    118119            this->pickup_->destroy();
    119120    }
     
    176177        if (this->isActive())
    177178        {
    178             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)
     179            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)
    179180
    180181            //! Iterate trough all Pawns.
     
    305306            {
    306307                if(pickup->pickup(target))
    307                 {
    308308                    this->decrementSpawnsRemaining();
    309                 }
    310309                else
    311310                {
     311                    this->selfDestruct_ = true;
    312312                    pickup->destroy();
    313313                }
     
    319319
    320320                if(pickup == NULL)
    321                 {
    322321                    COUT(1) << "PickupSpawner (&" << this << "): getPickup produced an error, no Pickupable created." << std::endl;
    323                 }
    324322                else
    325323                {
     324                    this->selfDestruct_ = true;
    326325                    pickup->destroy();
    327326                }
  • code/branches/presentation3/src/modules/pickup/PickupSpawner.h

    r7127 r7162  
    125125            Timer respawnTimer_; //!< Timer used for re-activating.
    126126
     127            bool selfDestruct_; //!< True if the PickupSpawner is selfdestructing.
     128
    127129            static const int INF = -1; //!< Constant for infinity.
    128130    };
  • code/branches/presentation3/src/modules/pickup/items/DronePickup.cc

    r7127 r7162  
    131131                Pawn* pawn = this->carrierToPawnHelper();
    132132                if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
    133                     this->destroy();
     133                    this->Pickupable::destroy();
    134134
    135135                //Attach to pawn
     
    155155            if(this->isOnce() || (this->isContinuous() ))
    156156            {
    157                 this->destroy();
     157                this->Pickupable::destroy();
    158158            }
    159159        }
  • code/branches/presentation3/src/modules/pickup/items/HealthPickup.cc

    r7127 r7162  
    143143            Pawn* pawn = this->carrierToPawnHelper();
    144144            if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
    145                 this->destroy();
     145                this->Pickupable::destroy();
    146146
    147147            //! Calculate the health that is added this tick.
     
    191191
    192192        //! If the pickup is not picked up nothing must be done.
    193         if(!this->isPickedUp())
     193        if(!this->isPickedUp()) //TODO: Needed?
    194194            return;
    195195
     
    201201                Pawn* pawn = this->carrierToPawnHelper();
    202202                if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
    203                     this->destroy();
     203                    this->Pickupable::destroy();
    204204
    205205                float health = 0;
     
    241241                {
    242242                    COUT(1) << "Something went horribly wrong in Health Pickup. PickupCarrier is no Pawn." << std::endl;
    243                     this->destroy();
     243                    this->Pickupable::destroy();
    244244                    return;
    245245                }
     
    256256            if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0))
    257257            {
    258                 this->destroy();
     258                this->Pickupable::destroy();
    259259            }
    260260        }
  • code/branches/presentation3/src/modules/pickup/items/InvisiblePickup.cc

    r7129 r7162  
    133133            if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
    134134            {
    135                 this->destroy();
     135                this->Pickupable::destroy();
    136136            }
    137137            else
  • code/branches/presentation3/src/modules/pickup/items/MetaPickup.cc

    r7150 r7162  
    3434#include "core/CoreIncludes.h"
    3535#include "core/XMLPort.h"
     36#include "worldentities/pawns/Pawn.h"
    3637#include "interfaces/PickupCarrier.h"
    3738#include "pickup/PickupIdentifier.h"
     
    4748    /*static*/ const std::string MetaPickup::metaTypeUse_s = "use";
    4849    /*static*/ const std::string MetaPickup::metaTypeDrop_s = "drop";
     50    /*static*/ const std::string MetaPickup::metaTypeDestroy_s = "destroy";
     51    /*static*/ const std::string MetaPickup::metaTypeDestroyCarrier_s = "destroyCarrier";
    4952
    5053    /**
     
    120123            if(this->getMetaTypeDirect() != pickupMetaType::none && carrier != NULL)
    121124            {
     125                if(this->getMetaTypeDirect() == pickupMetaType::destroyCarrier)
     126                {
     127                    Pawn* pawn = orxonox_cast<Pawn*>(carrier);
     128                    pawn->kill();
     129                    return;
     130                }
    122131                std::set<Pickupable*> pickups = carrier->getPickups();
    123                 //! Set all Pickupables carried by the PickupCarrier either to used or drop them, depending o the meta type.
     132                //! Set all Pickupables carried by the PickupCarrier either to used or drop them, depending on the meta type.
    124133                for(std::set<Pickupable*>::iterator it = pickups.begin(); it != pickups.end(); it++)
    125134                {
     
    136145                        if(pickup != NULL && pickup != this)
    137146                        {
    138                             pickup->drop(carrier);
     147                            pickup->drop();
     148                        }
     149                    }
     150                    if(this->getMetaTypeDirect() == pickupMetaType::destroy)
     151                    {
     152                        if(pickup != NULL && pickup != this)
     153                        {
     154                            pickup->Pickupable::destroy();
    139155                        }
    140156                    }
    141157                }
    142158            }
    143             this->destroy();
     159            this->Pickupable::destroy();
    144160        }
    145161    }
     
    180196            case pickupMetaType::drop:
    181197                return MetaPickup::metaTypeDrop_s;
     198            case pickupMetaType::destroy:
     199                return MetaPickup::metaTypeDestroy_s;
     200            case pickupMetaType::destroyCarrier:
     201                return MetaPickup::metaTypeDestroyCarrier_s;
    182202            default:
    183203                return BLANKSTRING;
     
    205225            this->setMetaTypeDirect(pickupMetaType::drop);
    206226        }
     227        else if(type == MetaPickup::metaTypeDestroy_s)
     228        {
     229            this->setMetaTypeDirect(pickupMetaType::destroy);
     230        }
     231        else if(type == MetaPickup::metaTypeDestroyCarrier_s)
     232        {
     233            this->setMetaTypeDirect(pickupMetaType::destroyCarrier);
     234        }
     235        else
     236            COUT(2) << "Invalid metaType '" << type << "' in MetaPickup." << std::endl;
    207237    }
    208238
  • code/branches/presentation3/src/modules/pickup/items/MetaPickup.h

    r7127 r7162  
    4848            none,
    4949            use,
    50             drop
     50            drop,
     51            destroy,
     52            destroyCarrier
    5153        };
    5254    }
     
    5456    /**
    5557    @brief
    56         The MetaPickup is a pickup that can, depending on the parameters, either drop all pickups of the PickupCarrier that picks it up, or use all the unused pickups of the PickupCarrier, that picks it up. The parameter to set for this is the metaType and it can be used with the values 'none', 'drop' and 'use'.
     58        The MetaPickup is a pickup that can, depending on the parameter 'metaType', do different things. If the 'metaType' is set to
     59        1) 'use', all the pickups, the PickupCarrier has, are immediately set to used upon pickup of the MetaPickup.
     60        2) 'drop', all the pickups, the PickupCarrier has, are immediately dropped upon pickup of the MetaPickup.
     61        3) 'destroy', all the pickups, the PickupCarrier has, are immediately destroyed upon pickup of the MetaPickup.
     62        4) 'destroyCarrier', the PickupCarrier is immediately destroyed upon pickup of the MetaPickup.
    5763    @author
    5864        Damian 'Mozork' Frick
     
    98104            static const std::string metaTypeUse_s;
    99105            static const std::string metaTypeDrop_s;
     106            static const std::string metaTypeDestroy_s;
     107            static const std::string metaTypeDestroyCarrier_s;
    100108
    101109
  • code/branches/presentation3/src/modules/pickup/items/ShieldPickup.cc

    r7127 r7162  
    155155        Pawn* pawn = this->carrierToPawnHelper();
    156156        if(pawn == NULL)
    157             this->destroy();
     157            this->Pickupable::destroy();
    158158
    159159        //! If the pickup has transited to used.
     
    181181                if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
    182182                {
    183                     this->destroy();
     183                    this->Pickupable::destroy();
    184184                }
    185185                else
  • code/branches/presentation3/src/modules/pickup/items/SpeedPickup.cc

    r7127 r7162  
    136136        Engine* engine = this->carrierToEngineHelper();
    137137        if(engine == NULL) //!< If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.
    138             this->destroy();
     138            this->Pickupable::destroy();
    139139
    140140        //! If the pickup has transited to used.
     
    161161                if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
    162162                {
    163                     this->destroy();
     163                    this->Pickupable::destroy();
    164164                }
    165165                else
Note: See TracChangeset for help on using the changeset viewer.