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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.