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/items
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • 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.