Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 16, 2010, 12:37:09 PM (14 years ago)
Author:
dafrick
Message:

Documenting and cleanup.

File:
1 edited

Legend:

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

    r7533 r7547  
    3434#include "core/CoreIncludes.h"
    3535#include "core/XMLPort.h"
    36 #include "worldentities/pawns/Pawn.h"
     36
    3737#include "interfaces/PickupCarrier.h"
    3838#include "pickup/PickupIdentifier.h"
     39#include "worldentities/pawns/Pawn.h"
    3940
    4041#include "MetaPickup.h"
     
    7980        this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier());
    8081
    81         this->setActivationTypeDirect(pickupActivationType::immediate);
    8282        this->setDurationTypeDirect(pickupDurationType::once);
    8383        this->metaType_ = pickupMetaType::none;
     
    117117        SUPER(MetaPickup, changedUsed);
    118118
    119         //! If the MetaPickup transited to used.
    120         if(this->isUsed())
     119        // If the MetaPickup transited to used, and the metaType is not none.
     120        if(this->isUsed() && this->metaType_ != pickupMetaType::none)
    121121        {
    122122            PickupCarrier* carrier = this->getCarrier();
    123123            if(this->getMetaTypeDirect() != pickupMetaType::none && carrier != NULL)
    124124            {
     125                // If the metaType is destroyCarrier, then the PickupCarrier is destroyed.
    125126                if(this->getMetaTypeDirect() == pickupMetaType::destroyCarrier)
    126127                {
     
    131132                }
    132133                std::set<Pickupable*> pickups = carrier->getPickups();
    133                 //! Set all Pickupables carried by the PickupCarrier either to used or drop them, depending on the meta type.
     134                // Iterate over all Pickupables of the PickupCarrier.
    134135                for(std::set<Pickupable*>::iterator it = pickups.begin(); it != pickups.end(); it++)
    135136                {
    136                     Pickup* pickup = dynamic_cast<Pickup*>(*it);
    137                     if(this->getMetaTypeDirect() == pickupMetaType::use)
     137                    Pickupable* pickup = (*it);
     138                    if(pickup == NULL || pickup == this)
     139                        continue;
     140
     141                    // If the metaType is use, then the Pickupable is set to used.
     142                    if(this->getMetaTypeDirect() == pickupMetaType::use && !pickup->isUsed())
    138143                    {
    139                         if(pickup != NULL && pickup != this && pickup->isOnUse() && !pickup->isUsed())
    140                         {
    141                             pickup->setUsed(true);
    142                         }
     144                        pickup->setUsed(true);
    143145                    }
    144                     if(this->getMetaTypeDirect() == pickupMetaType::drop)
     146                    // If the metaType is drop, then the Pickupable is dropped.
     147                    else if(this->getMetaTypeDirect() == pickupMetaType::drop)
    145148                    {
    146                         if(pickup != NULL && pickup != this)
    147                         {
    148                             pickup->drop();
    149                         }
     149                        pickup->drop();
    150150                    }
    151                     if(this->getMetaTypeDirect() == pickupMetaType::destroy)
     151                    // If the metaType is destroy, then the Pickupable is destroyed.
     152                    else if(this->getMetaTypeDirect() == pickupMetaType::destroy)
    152153                    {
    153                         if(pickup != NULL && pickup != this)
    154                         {
    155                             pickup->Pickupable::destroy();
    156                         }
     154                        pickup->Pickupable::destroy();
    157155                    }
    158156                }
     
    187185        Returns a string with the meta type of the MetaPickup.
    188186    */
    189     const std::string& MetaPickup::getMetaType(void)
     187    const std::string& MetaPickup::getMetaType(void) const
    190188    {
    191189        switch(this->getMetaTypeDirect())
Note: See TracChangeset for help on using the changeset viewer.