Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 11, 2010, 8:55:13 AM (14 years ago)
Author:
dafrick
Message:

Merged presentation3 branch into trunk.

Location:
code/trunk
Files:
26 edited
6 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/pickup/CMakeLists.txt

    r6711 r7163  
    11SET_SOURCE_FILES(PICKUP_SRC_FILES
     2  CollectiblePickup.cc
    23  DroppedPickup.cc
    34  Pickup.cc
     
    1718    PickupManager.h
    1819    PickupRepresentation.h
    19   DEFINE_SYMBOL
    20     "PICKUP_SHARED_BUILD"
    2120  PCH_FILE
    2221    PickupPrecompiledHeaders.h
  • code/trunk/src/modules/pickup/DroppedPickup.cc

    r6540 r7163  
    4141namespace orxonox
    4242{
    43    
     43
    4444    CreateFactory(DroppedPickup);
    45    
     45
    4646    /**
    4747    @brief
     
    5151    {
    5252        RegisterObject(DroppedPickup);
    53        
     53
    5454    }
    5555
     
    6767    */
    6868    DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 5, 1)
    69     {   
     69    {
    7070        RegisterObject(DroppedPickup);
    7171
    7272        this->setPosition(carrier->getCarrierPosition());
    7373        this->setActive(false);
    74        
     74
    7575        //TODO: Do more elegantly.
    7676        this->startRespawnTimer();
  • code/trunk/src/modules/pickup/DroppedPickup.h

    r6540 r7163  
    4141namespace orxonox
    4242{
    43    
     43
    4444    /**
    4545    @brief
  • code/trunk/src/modules/pickup/Pickup.cc

    • Property svn:eol-style set to native
    r6709 r7163  
    4848    /*static*/ const std::string Pickup::durationTypeOnce_s = "once";
    4949    /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous";
     50
     51    CreateUnloadableFactory(Pickup);
    5052
    5153    Pickup::Pickup(BaseObject* creator) : BaseObject(creator)
     
    146148    void Pickup::setActivationType(const std::string& type)
    147149    {
    148         if(type == activationTypeImmediate_s)
     150        if(Pickup::activationTypeImmediate_s.compare(type) == 0)
    149151        {
    150152            this->activationType_ = pickupActivationType::immediate;
    151153        }
    152         else if(type == activationTypeOnUse_s)
     154        else if(Pickup::activationTypeOnUse_s.compare(type) == 0)
    153155        {
    154156            this->activationType_ = pickupActivationType::onUse;
     
    168170    void Pickup::setDurationType(const std::string& type)
    169171    {
    170         if(type == durationTypeOnce_s)
     172        if(Pickup::durationTypeOnce_s.compare(type) == 0)
    171173        {
    172174            this->durationType_ = pickupDurationType::once;
    173175        }
    174         else if(type == durationTypeContinuous_s)
     176        else if(Pickup::durationTypeContinuous_s.compare(type) == 0)
    175177        {
    176178            this->durationType_ = pickupDurationType::continuous;
     
    192194
    193195        //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.
    194         if(this->getCarrier() != NULL && this->isPickedUp() && this->isImmediate())
     196        if(this->isPickedUp() && this->isImmediate())
    195197        {
    196198            this->setUsed(true);
  • code/trunk/src/modules/pickup/Pickup.h

    • Property svn:eol-style set to native
    r6728 r7163  
    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
    79         protected:
     79        public:
    8080            Pickup(BaseObject* creator); //!< Constructor.
    81 
    82         public:
    8381            virtual ~Pickup(); //!< Destructor.
    8482
     
    167165        private:
    168166            void initialize(void); //!< Initializes the member variables.
    169            
     167
    170168            //TODO: Problems, when there are more Timers needed? Solutions?
    171169            Timer durationTimer_; //!< Timer at the disposal of each Class implementing Pickup.
  • code/trunk/src/modules/pickup/PickupCollection.cc

    r6901 r7163  
    3535#include "core/XMLPort.h"
    3636#include "interfaces/PickupCarrier.h"
     37#include "CollectiblePickup.h"
    3738#include "DroppedPickup.h"
    3839#include "PickupCollectionIdentifier.h"
     
    4243namespace orxonox
    4344{
    44  
     45
    4546    CreateFactory(PickupCollection);
    4647
     
    5253    {
    5354        RegisterObject(PickupCollection);
    54        
     55
    5556        this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier(this);
    56     }
    57    
     57        this->usedCounter_ = 0;
     58        this->pickedUpCounter_ = 0;
     59        this->disabledCounter_ = 0;
     60        this->processingUsed_ = false;
     61        this->processingPickedUp_ = false;
     62    }
     63
    5864    /**
    5965    @brief
     
    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     }
    71    
     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();
     77    }
     78
    7279    /**
    7380    @brief
     
    7784    {
    7885        SUPER(PickupCollection, XMLPort, xmlelement, mode);
    79        
    80         XMLPortObject(PickupCollection, Pickupable, "pickupables", addPickupable, getPickupable, xmlelement, mode);
    81        
     86
     87        XMLPortObject(PickupCollection, CollectiblePickup, "pickupables", addPickupable, getPickupable, xmlelement, mode);
     88
    8289        this->initializeIdentifier();
    8390    }
    84    
     91
    8592    /**
    8693    @brief
     
    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());
    94         }
    95     }
    96    
     98        for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
     99        {
     100            this->pickupCollectionIdentifier_->addPickup((*it)->getPickupIdentifier());
     101        }
     102    }
     103
    97104    /**
    98105    @brief
     
    103110    {
    104111        SUPER(PickupCollection, changedUsed);
    105        
    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         }
    111     }
    112    
     112
     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);
     141    }
     142
    113143    /**
    114144    @brief
     
    119149    {
    120150        SUPER(PickupCollection, changedCarrier);
    121        
    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));
    126         }
    127     }
    128    
     151
     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));
     159        }
     160    }
     161
    129162    /**
    130163    @brief
     
    135168    {
    136169        SUPER(PickupCollection, changedPickedUp);
    137        
    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         }
    143     }
    144    
     170
     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;
     199    }
     200
    145201    /**
    146202    @brief
     
    154210        if(item == NULL)
    155211            item = new PickupCollection(this);
    156        
     212
    157213        SUPER(PickupCollection, clone, item);
    158        
     214
    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
    167224        pickup->initializeIdentifier();
    168225    }
    169    
     226
    170227    /**
    171228    @brief
     
    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        }
    185        
     242
    186243        return true;
    187244    }
    188    
     245
    189246    /**
    190247    @brief
     
    198255        return this->pickupCollectionIdentifier_;
    199256    }
    200    
     257
    201258    /**
    202259    @brief
     
    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;
    213        
    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);
     270
     271        pickup->addToCollection(this);
     272        this->pickups_.push_back(pickup);
    216273        return true;
    217274    }
    218    
     275
    219276    /**
    220277    @brief
     
    227284    const Pickupable* PickupCollection::getPickupable(unsigned int index)
    228285    {
    229         return this->pickups_[index].get();
    230     }
    231        
     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_++;
     331    }
     332
    232333    /**
    233334    @brief
     
    245346        return true;
    246347    }
    247    
     348
    248349}
  • code/trunk/src/modules/pickup/PickupCollection.h

    r6731 r7163  
    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    {
    55        
     55
    5656        public:
    57            
    5857            PickupCollection(BaseObject* creator); //!< Default Constructor.
    5958            virtual ~PickupCollection(); //!< Destructor.
    60            
     59
    6160            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates an instance of this Class through XML.
    6261
     
    6463            virtual void changedCarrier(void); //!< Is called when the pickup has changed its PickupCarrier.
    6564            virtual void changedPickedUp(void); //!< Is called when the pickup has transited from picked up to dropped or the other way around.
    66            
     65
    6766            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    68            
     67
    6968            virtual bool isTarget(PickupCarrier* carrier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this PickupCollection.
    70            
     69
    7170            virtual const PickupIdentifier* getPickupIdentifier(void); //!< Get the PickupIdentifier of this PickupCollection.
    72            
    73             bool addPickupable(Pickupable* pickup); //!< Add the input Pickupable to list of Pickupables combined by this PickupCollection.
     71
     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.
    75            
     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.
     78
    7679        protected:
    7780            void initializeIdentifier(void); //!< Initializes the PickupIdentifier for this pickup.
     81
     82            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
     83
     84            PickupCollectionIdentifier* pickupCollectionIdentifier_; //!< The PickupCollectionIdentifier of this PickupCollection. Is used to distinguish different PickupCollections amongst themselves.
     85
     86        private:
     87            void changedUsedAction(void); //!< Helper method.
     88            void changedPickedUpAction(void); //!< Helper method.
    7889           
    79             virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    80            
    81             PickupCollectionIdentifier* pickupCollectionIdentifier_; //!< The PickupCollectionIdentifier of this PickupCollection. Is used to distinguish different PickupCollections amongst themselves.
    82            
    83         private:
    84            
    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.
    86        
     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.
     91
     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.
     98
    8799    };
    88    
     100
    89101}
    90102
  • code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc

    • Property svn:eol-style set to native
    r6538 r7163  
    3838namespace orxonox
    3939{
    40    
     40
    4141    /**
    4242    @brief
     
    4747        RegisterObject(PickupCollectionIdentifier);
    4848    }
    49    
     49
    5050    /**
    5151    @brief
     
    5454    PickupCollectionIdentifier::~PickupCollectionIdentifier()
    5555    {
    56        
     56
    5757    }
    5858
     
    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);
    72        
    73         //! If the input PickupIdentifier 'identifier' is no PickupCollectionIdentifier then just the two PickupIdentifiers are compared.
     72
     73        // If the input PickupIdentifier 'identifier' is no PickupCollectionIdentifier then just the two PickupIdentifiers are compared.
    7474        if(collectionIdentifier == NULL)
    7575        {
    7676            return this->PickupIdentifier::compare(identifier);
    7777        }
    78        
    79         //! If the number of Pickupables each of the two PickupCollectionIdentifiers contain differ, the one with less is considered smaller.
     78
     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();
    82        
    83         //! Compare the Pickupables of the two PickupCollectionIdentifiers one after the other. the one with the first 'smaller' one is considered smaller.
     82
     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++)
    8686        {
    87            
     87
    8888            if((*it)->compare(*it2) < 0)
    8989                return -1;
     
    9191                return 1;
    9292        }
    93        
     93
    9494        //! Means they are equal.
    9595        return 0;
    9696    }
    97    
     97
    9898    /**
    9999    @brief
     
    106106        this->identifiers_.insert(identifier);
    107107    }
    108    
     108
    109109}
    110110
  • code/trunk/src/modules/pickup/PickupCollectionIdentifier.h

    • Property svn:eol-style set to native
    r6538 r7163  
    5454    class _PickupExport PickupCollectionIdentifier : public PickupIdentifier
    5555    {
    56        
     56
    5757        public:
    5858            PickupCollectionIdentifier(Pickupable* pickup); //!< Constructor.
    5959            ~PickupCollectionIdentifier(); //!< Destructor.
    60            
     60
    6161            virtual int compare(const PickupIdentifier* identifier) const; //!< Compares a PickupCollectionIdentifier with a PickupIdentifier.
    62            
     62
    6363            void addPickup(const PickupIdentifier* identifier); //!< Add a Pickupable to the PickupCollectionIdentifier.
    64            
     64
    6565        private:
    6666            std::set<const PickupIdentifier*, PickupIdentifierCompare> identifiers_; //!< The set of PickupIdentifiers of the Pickupables the PickupCollection with this PickupCollectionIdentifier consists of, ordered by the rule set by PickupIdentifierCompare.
    67            
     67
    6868    };
    69    
     69
    7070}
    7171
  • code/trunk/src/modules/pickup/PickupManager.cc

    • Property svn:eol-style set to native
    r6752 r7163  
    3939#include "core/ScopedSingletonManager.h"
    4040#include "core/Identifier.h"
     41#include "util/Convert.h"
    4142#include "interfaces/PickupCarrier.h"
    4243#include "infos/PlayerInfo.h"
    4344#include "worldentities/pawns/Pawn.h"
     45#include "CollectiblePickup.h"
    4446#include "PickupRepresentation.h"
    4547
     
    5052    // Register tolua_open function when loading the library
    5153    DeclareToluaInterface(Pickup);
    52    
    53     ManageScopedSingleton(PickupManager, ScopeID::Graphics, false);
    54    
     54
     55    ManageScopedSingleton(PickupManager, ScopeID::Root, false);
     56
    5557    /*static*/ const std::string PickupManager::guiName_s = "PickupInventory";
    56    
     58
    5759    /**
    5860    @brief
     
    6264    {
    6365        RegisterRootObject(PickupManager);
    64        
     66
     67        //TODO: This doesn't work, yet.
     68        if( GameMode::showsGraphics() )
     69        {
     70            GUIManager::getInstance().loadGUI(PickupManager::guiName_s);
     71        }
    6572        this->defaultRepresentation_ = new PickupRepresentation();
    66        
     73
    6774        COUT(3) << "PickupManager created." << std::endl;
    6875    }
    69    
     76
    7077    /**
    7178    @brief
     
    7784        if(this->defaultRepresentation_ != NULL)
    7885            this->defaultRepresentation_->destroy();
    79        
     86
    8087        this->representations_.clear();
    81        
     88
    8289        COUT(3) << "PickupManager destroyed." << std::endl;
    8390    }
    84    
     91
    8592    /**
    8693    @brief
     
    95102    */
    96103    bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
    97     {       
     104    {
    98105        if(identifier == NULL || representation == NULL || this->representations_.find(identifier) != this->representations_.end()) //!< If the Pickupable already has a Representation registered.
    99106            return false;
    100        
     107
    101108        this->representations_[identifier] = representation;
    102        
     109
    103110        COUT(4) << "PickupRepresentation " << representation << " registered with the PickupManager." << std::endl;
    104111        return true;
    105112    }
    106    
     113
    107114    /**
    108115    @brief
     
    116123    */
    117124    bool PickupManager::unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
    118     {       
     125    {
    119126        if(identifier == NULL || representation == NULL)
    120127            return false;
    121        
     128
    122129        std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
    123130        if(it == this->representations_.end()) //!< If the Pickupable is not registered in the first place.
    124131            return false;
    125        
     132
    126133        this->representations_.erase(it);
    127        
     134
    128135        COUT(4) << "PickupRepresentation " << representation << " unregistered with the PickupManager." << std::endl;
    129136        return true;
    130137    }
    131    
     138
    132139    /**
    133140    @brief
     
    146153            return this->defaultRepresentation_;
    147154        }
    148        
     155
    149156        return it->second;
    150157    }
    151    
    152     PickupCarrier* PickupManager::getPawn(void)
    153     {
     158
     159    int PickupManager::getNumPickups(void)
     160    {
     161        this->pickupsList_.clear();
     162
    154163        PlayerInfo* player = GUIManager::getInstance().getPlayer(PickupManager::guiName_s);
     164        PickupCarrier* carrier = NULL;
    155165        if (player != NULL)
    156             return dynamic_cast<PickupCarrier*>(player->getControllableEntity());
     166            carrier = dynamic_cast<PickupCarrier*>(player->getControllableEntity());
    157167        else
    158             return NULL;
    159     }
    160    
    161     int PickupManager::getNumCarrierChildren(PickupCarrier* carrier)
    162     {
    163         if(carrier == NULL)
    164168            return 0;
    165         return carrier->getNumCarrierChildren();
    166     }
    167            
    168     PickupCarrier* PickupManager::getCarrierChild(int index, PickupCarrier* carrier)
    169     {
    170         if(carrier == NULL)
    171             return NULL;
    172         return carrier->getCarrierChild(index);
    173     }
    174    
    175     const std::string& PickupManager::getCarrierName(orxonox::PickupCarrier* carrier)
    176     {
    177         if(carrier == NULL)
    178             return BLANKSTRING;
    179         return carrier->getCarrierName();
    180     }
    181    
    182     PickupRepresentation* PickupManager::getPickupRepresentation(int index, PickupCarrier* carrier)
    183     {
    184         Pickupable* pickup = carrier->getPickup(index);
    185         if(pickup == NULL)
    186             return NULL;
    187        
    188         return this->getRepresentation(pickup->getPickupIdentifier());
    189     }
    190    
    191     int PickupManager::getNumPickups(PickupCarrier* carrier)
    192     {
    193         if(carrier == NULL)
    194             return 0;
    195         return carrier->getNumPickups();
    196     }
    197    
    198     void PickupManager::dropPickup(int index, PickupCarrier* carrier)
    199     {
    200         Pickupable* pickup = carrier->getPickup(index);
    201         if(pickup != NULL)
    202             carrier->drop(pickup);
    203     }
    204    
    205     void PickupManager::usePickup(int index, PickupCarrier* carrier, bool use)
    206     {
    207         Pickupable* pickup = carrier->getPickup(index);
    208         if(pickup != NULL)
     169
     170        std::vector<PickupCarrier*>* carriers = this->getAllCarriers(carrier);
     171        for(std::vector<PickupCarrier*>::iterator it = carriers->begin(); it != carriers->end(); it++)
     172        {
     173            std::set<Pickupable*> pickups = (*it)->getPickups();
     174            for(std::set<Pickupable*>::iterator pickup = pickups.begin(); pickup != pickups.end(); pickup++)
     175            {
     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)));
     179            }
     180        }
     181        delete carriers;
     182
     183        this->pickupsIterator_ = this->pickupsList_.begin();
     184        return this->pickupsList_.size();
     185    }
     186
     187    std::vector<PickupCarrier*>* PickupManager::getAllCarriers(PickupCarrier* carrier)
     188    {
     189        //TODO: More efficiently.
     190        std::vector<PickupCarrier*>* carriers = new std::vector<PickupCarrier*>();
     191        carriers->insert(carriers->end(), carrier);
     192        std::vector<PickupCarrier*>* children = carrier->getCarrierChildren();
     193        for(std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)
     194        {
     195            std::vector<PickupCarrier*>* childrensChildren = this->getAllCarriers(*it);
     196            for(std::vector<PickupCarrier*>::iterator it2 = childrensChildren->begin(); it2 != childrensChildren->end(); it2++)
     197            {
     198                carriers->insert(carriers->end(), *it2);
     199            }
     200            delete childrensChildren;
     201        }
     202        delete children;
     203        return carriers;
     204    }
     205
     206    void PickupManager::dropPickup(orxonox::Pickupable* pickup)
     207    {
     208        std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup);
     209        if(pickup == NULL || it == this->pickupsList_.end() || it->second.get() == NULL)
     210            return;
     211
     212        if(!pickup->isPickedUp())
     213            return;
     214
     215        PickupCarrier* carrier = pickup->getCarrier();
     216        if(pickup != NULL && carrier != NULL)
     217        {
     218            pickup->drop(carrier);
     219        }
     220    }
     221
     222    void PickupManager::usePickup(orxonox::Pickupable* pickup, bool use)
     223    {
     224        std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup);
     225        if(pickup == NULL || it == this->pickupsList_.end() || it->second.get() == NULL)
     226            return;
     227
     228        if(!pickup->isPickedUp())
     229            return;
     230
     231        PickupCarrier* carrier = pickup->getCarrier();
     232        if(pickup != NULL && carrier != NULL)
    209233            pickup->setUsed(use);
    210234    }
    211    
     235
    212236}
  • code/trunk/src/modules/pickup/PickupManager.h

    • Property svn:eol-style set to native
    r6725 r7163  
    3939#include <map>
    4040#include "util/Singleton.h"
     41#include "core/WeakPtr.h"
    4142#include "pickup/PickupIdentifier.h"
    4243#include "PickupRepresentation.h"
     
    5960    { // tolua_export
    6061        friend class Singleton<PickupManager>;
    61        
     62
    6263        public:
    6364            PickupManager();
    6465            virtual ~PickupManager();
    65            
     66
    6667            static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); } // tolua_export
    67            
     68
    6869            bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
    6970            bool unregisterRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Unegisters a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
    7071            PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
    71            
     72
    7273            // tolua_begin
    73             orxonox::PickupCarrier* getPawn(void);
    74            
    75             int getNumCarrierChildren(orxonox::PickupCarrier* carrier);
    76             orxonox::PickupCarrier* getCarrierChild(int index, orxonox::PickupCarrier* carrier);
    77            
    78             const std::string& getCarrierName(orxonox::PickupCarrier* carrier);
    79            
    80             int getNumPickups(orxonox::PickupCarrier* carrier);
    81             PickupRepresentation* getPickupRepresentation(int index, orxonox::PickupCarrier* carrier);
    82             void dropPickup(int index, orxonox::PickupCarrier* carrier);
    83             void usePickup(int index, orxonox::PickupCarrier* carrier, bool use);
     74            int getNumPickups(void);
     75            orxonox::Pickupable* popPickup(void) { return (this->pickupsIterator_++)->first; }
     76            orxonox::PickupRepresentation* getPickupRepresentation(orxonox::Pickupable* pickup) { if(pickup != NULL) return this->getRepresentation(pickup->getPickupIdentifier()); return NULL; }
     77
     78            void dropPickup(orxonox::Pickupable* pickup);
     79            void usePickup(orxonox::Pickupable* pickup, bool use);
     80            bool isValidPickup(orxonox::Pickupable* pickup) { std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); if(it == this->pickupsList_.end()) return false; return it->second.get() != NULL; }
    8481            // tolua_end
    85            
     82
    8683        private:
    8784            static PickupManager* singletonPtr_s;
    8885            static const std::string guiName_s;
    89            
     86
    9087            PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
    9188            std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
    92        
     89
     90            std::map<Pickupable*, WeakPtr<Pickupable> > pickupsList_;
     91            std::map<Pickupable*, WeakPtr<Pickupable> >::iterator pickupsIterator_;
     92
     93            std::vector<PickupCarrier*>* getAllCarriers(PickupCarrier* carrier);
     94
    9395    }; // tolua_export
    94    
     96
    9597} // tolua_export
    9698
  • code/trunk/src/modules/pickup/PickupPrereqs.h

    r6711 r7163  
    4343//-----------------------------------------------------------------------
    4444
    45 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
     45#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(PICKUP_STATIC_BUILD)
    4646#  ifdef PICKUP_SHARED_BUILD
    4747#    define _PickupExport __declspec(dllexport)
     
    6565namespace orxonox
    6666{
    67    
     67
     68    class CollectiblePickup;
    6869    class DroppedPickup;
    6970    class Pickup;
     
    7576
    7677    //items
     78    class DronePickup;
    7779    class HealthPickup;
    7880    class InvisiblePickup;
    7981    class MetaPickup;
    8082    class SpeedPickup;
     83    class ShieldPickup;
    8184
    8285}
  • code/trunk/src/modules/pickup/PickupRepresentation.cc

    • Property svn:eol-style set to native
    r6725 r7163  
    4141namespace orxonox
    4242{
    43    
     43
    4444    CreateFactory(PickupRepresentation);
    45    
     45
    4646    /**
    4747    @brief
     
    5252    {
    5353        RegisterObject(PickupRepresentation);
    54        
     54
    5555        this->initialize();
    5656    }
    57    
     57
    5858    /**
    5959    @brief
     
    6363    {
    6464        RegisterObject(PickupRepresentation);
    65        
     65
    6666        this->initialize();
    6767    }
    68    
     68
    6969    /**
    7070    @brief
     
    7575        if(this->spawnerRepresentation_ != NULL)
    7676            this->spawnerRepresentation_->destroy();
    77        
     77
    7878        if(this->pickup_ != NULL)
    7979            PickupManager::getInstance().unregisterRepresentation(this->pickup_->getPickupIdentifier(), this);
    8080    }
    81    
     81
    8282    /**
    8383    @brief
     
    9191        this->inventoryRepresentation_ = "Default";
    9292    }
    93    
     93
    9494    /**
    9595    @brief
     
    9999    {
    100100        SUPER(PickupRepresentation, XMLPort, xmlelement, mode);
    101        
     101
    102102        XMLPortParam(PickupRepresentation, "pickupName", setPickupName, getPickupName, xmlelement, mode);
    103103        XMLPortParam(PickupRepresentation, "pickupDescription", setPickupDescription, getPickupDescription, xmlelement, mode);
     
    106106        XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode);
    107107        XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode);
    108        
     108
    109109        PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this); //!< Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents.
    110        
     110
    111111        if(this->spawnerRepresentation_ != NULL)
    112112            this->spawnerRepresentation_->setVisible(false);
    113        
     113
    114114        COUT(4) << "PickupRepresentation created: name: '" << this->name_ << "', description: '" << this->description_ << "', spawnerTemplate: '" << this->spawnerTemplate_ << "'." << std::endl;
    115115    }
    116    
     116
    117117    /**
    118118    @brief
     
    136136            this->addTemplate(this->spawnerTemplate_);
    137137        }
    138        
     138
    139139        StaticEntity* representation = this->spawnerRepresentation_;
    140140        representation->setVisible(true);
    141        
     141
    142142        this->addTemplate(this->spawnerTemplate_);
    143143        this->spawnerRepresentation_->setVisible(false);
    144        
     144
    145145        return representation;
    146146    }
    147    
     147
    148148    /**
    149149    @brief
     
    171171        return representation;
    172172    }
    173    
     173
    174174}
  • code/trunk/src/modules/pickup/PickupRepresentation.h

    • Property svn:eol-style set to native
    r6711 r7163  
    5656        : public BaseObject
    5757    { // tolua_export
    58        
     58
    5959        public:
    6060            PickupRepresentation(); //!< Constructor
    6161            PickupRepresentation(BaseObject* creator); //!< Default constructor.
    6262            virtual ~PickupRepresentation(); //!< Destructor.
    63            
     63
    6464            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    65            
     65
    6666            /**
    6767            @brief Set the name of the Pickupable represented by this PickupRepresentation.
     
    102102            inline void setPickup(Pickupable* pickup)
    103103                { this->pickup_ = pickup; }
    104                
     104
    105105            /**
    106106            @brief Get the name of the Pickupable represented by this PickupRepresentation.
     
    138138            inline const Pickupable* getPickup(unsigned int index)
    139139                { if(index == 0) return this->pickup_; return NULL; }
    140                
     140
    141141            StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner.
    142        
     142
    143143        private:
    144144            void initialize(void); //!< Initializes the member variables of this PickupRepresentation.
    145145            StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner.
    146            
     146
    147147            std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation.
    148148            std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation.
    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?
    152            
     151            std::string inventoryRepresentation_; //!< The name of an image representing the pickup in the PickupInventory.
     152
    153153            Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.
    154            
     154
    155155    }; // tolua_export
    156156
    157157} // tolua_export
    158    
     158
    159159#endif // _PickupRepresentation_H__
  • code/trunk/src/modules/pickup/PickupSpawner.cc

    r6711 r7163  
    5555    {
    5656        RegisterObject(PickupSpawner);
    57        
     57
    5858        this->initialize();
    5959    }
     
    7676    {
    7777        RegisterObject(PickupSpawner);
    78        
     78
    7979        this->initialize();
    80  
     80
    8181        this->pickup_ = pickup;
    8282
     
    8484        this->respawnTime_ = respawnTime;
    8585        this->setMaxSpawnedItems(maxSpawnedItems);
    86        
     86
    8787        if(this->pickup_ == NULL)
    8888        {
     
    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    }
     
    132133
    133134        XMLPortObject(PickupSpawner, Pickupable, "pickup", setPickupable, getPickupable, xmlelement, mode);
    134        
     135
    135136        XMLPortParam(PickupSpawner, "triggerDistance", setTriggerDistance, getTriggerDistance, xmlelement, mode);
    136137        XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode);
    137138        XMLPortParam(PickupSpawner, "maxSpawnedItems", setMaxSpawnedItems, getMaxSpawnedItems, xmlelement, mode);
    138        
     139
    139140        if(this->pickup_ == NULL)
    140141        {
     
    150151        }
    151152    }
    152    
     153
    153154    /**
    154155    @brief
     
    161162        this->setVisible(this->isActive());
    162163    }
    163      
     164
    164165    /**
    165166    @brief
     
    172173    {
    173174        SUPER(PickupSpawner, tick, dt);
    174        
     175
    175176        //! If the PickupSpawner is active.
    176177        if (this->isActive())
    177178        {
     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)
     180
    178181            //! Iterate trough all Pawns.
    179182            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
     
    189192        }
    190193    }
    191    
     194
    192195    /**
    193196    @brief
     
    201204        this->spawnsRemaining_ = items;
    202205    }
    203    
     206
    204207    /**
    205208    @brief
     
    223226        else
    224227        {
    225             COUT(3) << "PickupSpawner empty, selfdestruct initialized." << std::endl;
     228            COUT(4) << "PickupSpawner (&" << this << ") empty, selfdestruct initialized." << std::endl;
    226229            this->setActive(false);
    227230            this->destroy();
    228231        }
    229232    }
    230    
     233
    231234    /**
    232235    @brief
     
    237240        this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));
    238241    }
    239    
     242
    240243    /**
    241244    @brief
     
    248251        if(this->pickup_ != NULL)
    249252        {
    250             COUT(1) << "In PickupSpawner: setPickupable called, with this->pickup_ already set." << std::endl;
     253            COUT(1) << "In PickupSpawner (&" << this << "): setPickupable called, with this->pickup_ already set." << std::endl;
    251254            return;
    252255        }
    253256        if(pickup == NULL)
    254257        {
    255             COUT(1) << "In PickupSpawner: Argument of setPickupable is NULL." << std::endl;
     258            COUT(1) << "In PickupSpawner (&" << this << "): Argument of setPickupable is NULL." << std::endl;
    256259            return;
    257260        }
    258        
     261
    259262        this->pickup_ = pickup;
    260263    }
    261    
     264
    262265    /**
    263266    @brief
     
    282285        if (this->isActive()) //!< Checks whether PickupSpawner is active.
    283286        {
    284             COUT(3) << "PickupSpawner triggered and active." << std::endl;
    285            
     287            COUT(4) << "PickupSpawner (&" << this << ") triggered and active." << std::endl;
     288
    286289            PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn);
    287290            if(carrier == NULL)
     
    290293                return;
    291294            }
    292            
     295
    293296            if(!carrier->isTarget(this->pickup_))
    294297            {
    295                 COUT(4) << "PickupSpawner triggered but Pawn wasn't a target of the Pickupable." << std::endl;
     298                COUT(4) << "PickupSpawner (&" << this << ") triggered but Pawn wasn't a target of the Pickupable." << std::endl;
    296299                return;
    297300            }
    298            
     301
    299302            PickupCarrier* target = carrier->getTarget(this->pickup_);
    300303            Pickupable* pickup = this->getPickup();
    301            
     304
    302305            if(target != NULL && pickup != NULL)
    303306            {
    304                 if(target->pickup(pickup))
    305                 {
     307                if(pickup->pickup(target))
    306308                    this->decrementSpawnsRemaining();
    307                 }
    308309                else
    309310                {
     311                    this->selfDestruct_ = true;
    310312                    pickup->destroy();
    311313                }
     
    314316            {
    315317                if(target == NULL)
    316                     COUT(1) << "PickupSpawner: Pickupable has no target." << std::endl;
    317                
     318                    COUT(1) << "PickupSpawner (&" << this << "): Pickupable has no target." << std::endl;
     319
    318320                if(pickup == NULL)
    319                 {
    320                     COUT(1) << "PickupSpawner: getPickup produced an error, no Pickupable created." << std::endl;
    321                 }
     321                    COUT(1) << "PickupSpawner (&" << this << "): getPickup produced an error, no Pickupable created." << std::endl;
    322322                else
    323323                {
     324                    this->selfDestruct_ = true;
    324325                    pickup->destroy();
    325326                }
     
    333334    @return
    334335        The Pickupable created.
    335     */   
     336    */
    336337    Pickupable* PickupSpawner::getPickup(void)
    337338    {
     
    341342            return NULL;
    342343        }
    343        
     344
    344345        Pickupable* pickup = this->pickup_->clone();
    345346        return pickup;
     
    352353    void PickupSpawner::respawnTimerCallback()
    353354    {
    354         COUT(3) << "PickupSpawner reactivated." << std::endl;
     355        COUT(4) << "PickupSpawner (&" << this << ") reactivated." << std::endl;
    355356
    356357        this->setActive(true);
  • code/trunk/src/modules/pickup/PickupSpawner.h

    r6540 r7163  
    101101        protected:
    102102            void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns.
    103                        
     103
    104104            void startRespawnTimer(void);
    105            
     105
    106106            virtual Pickupable* getPickup(void); //!< Creates a new Pickupable.
    107            
     107
    108108            void setPickupable(Pickupable* pickup); //!< Sets a Pickupable for the PickupSpawner to spawn.
    109109            const Pickupable* getPickupable(void); //!< Get the Pickupable that is spawned by this PickupSpawner.
    110            
     110
    111111            Pickupable* pickup_; //!< The pickup to be spawned.
    112112
    113113        private:
    114114            void initialize(void);
    115            
     115
    116116            void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough.
    117117            void respawnTimerCallback(); //!< Method called when the timer runs out.
     
    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/trunk/src/modules/pickup/items/CMakeLists.txt

    • Property svn:eol-style set to native
    r6710 r7163  
    33  InvisiblePickup.cc
    44  MetaPickup.cc
     5  DronePickup.cc
    56  SpeedPickup.cc
     7  ShieldPickup.cc
    68)
  • code/trunk/src/modules/pickup/items/HealthPickup.cc

    r6709 r7163  
    4545namespace orxonox
    4646{
    47    
     47
    4848    /*static*/ const std::string HealthPickup::healthTypeLimited_s = "limited";
    4949    /*static*/ const std::string HealthPickup::healthTypeTemporary_s = "temporary";
    5050    /*static*/ const std::string HealthPickup::healthTypePermanent_s = "permanent";
    51    
     51
    5252    CreateFactory(HealthPickup);
    53    
     53
    5454    /**
    5555    @brief
     
    5959    {
    6060        RegisterObject(HealthPickup);
    61        
     61
    6262        this->initialize();
    6363    }
    64    
     64
    6565    /**
    6666    @brief
     
    6969    HealthPickup::~HealthPickup()
    7070    {
    71        
    72     }
    73    
    74     /**
    75     @brief 
     71
     72    }
     73
     74    /**
     75    @brief
    7676        Initializes the member variables.
    7777    */
    7878    void HealthPickup::initialize(void)
    79     {       
     79    {
    8080        this->health_ = 0;
    8181        this->healthRate_ = 0;
     
    8383        this->maxHealthSave_ = 0;
    8484        this->maxHealthOverwrite_ = 0;
    85        
     85
    8686        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
    8787    }
    88    
     88
    8989    /**
    9090    @brief
     
    9898        std::string val1 = stream.str();
    9999        this->pickupIdentifier_->addParameter(type1, val1);
    100        
     100
    101101        std::string val2 = this->getHealthType();
    102102        std::string type2 = "healthType";
    103103        this->pickupIdentifier_->addParameter(type2, val2);
    104        
     104
    105105        stream.clear();
    106106        stream << this->getHealthRate();
     
    109109        this->pickupIdentifier_->addParameter(type3, val3);
    110110    }
    111    
     111
    112112    /**
    113113    @brief
     
    117117    {
    118118        SUPER(HealthPickup, XMLPort, xmlelement, mode);
    119        
     119
    120120        XMLPortParam(HealthPickup, "health", setHealth, getHealth, xmlelement, mode);
    121121        XMLPortParam(HealthPickup, "healthRate", setHealthRate, getHealthRate, xmlelement, mode);
    122122        XMLPortParam(HealthPickup, "healthType", setHealthType, getHealthType, xmlelement, mode);
    123        
     123
    124124        if(!this->isContinuous())
    125125            this->healthRate_ = 0.0;
    126        
     126
    127127        this->initializeIdentifier();
    128128    }
    129    
     129
    130130    /**
    131131    @brief
     
    138138    {
    139139        SUPER(HealthPickup, tick, dt);
    140        
     140
    141141        if(this->isContinuous() && this->isUsed())
    142142        {
    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();
    146            
     145                this->Pickupable::destroy();
     146
    147147            //! Calculate the health that is added this tick.
    148148            float health = dt*this->getHealthRate();
     
    152152            float fullHealth = pawn->getHealth() + health;
    153153            this->setHealth(this->getHealth()-health);
    154                    
     154
    155155            switch(this->getHealthTypeDirect())
    156156            {
     
    173173                    COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
    174174            }
    175            
     175
    176176            //! If all health has been transfered.
    177177            if(this->getHealth() == 0)
     
    181181        }
    182182    }
    183    
     183
    184184    /**
    185185    @brief
     
    189189    {
    190190        SUPER(HealthPickup, changedUsed);
    191        
     191
    192192        //! If the pickup is not picked up nothing must be done.
    193         if(!this->isPickedUp())
     193        if(!this->isPickedUp()) //TODO: Needed?
    194194            return;
    195        
     195
    196196        //! If the pickup has transited to used.
    197197        if(this->isUsed())
     
    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();
    204                
     203                    this->Pickupable::destroy();
     204
    205205                float health = 0;
    206206                switch(this->getHealthTypeDirect())
     
    226226                        COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
    227227                }
    228                
     228
    229229                //! The pickup has been used up.
    230230                this->setUsed(false);
     
    237237                PickupCarrier* carrier = this->getCarrier();
    238238                Pawn* pawn = dynamic_cast<Pawn*>(carrier);
    239                
     239
    240240                if(pawn == NULL)
    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                }
    246                
     246
    247247                if(pawn->getMaxHealth() == this->maxHealthOverwrite_)
    248248                {
     
    252252                }
    253253            }
    254            
     254
    255255            //! If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
    256256            if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0))
    257257            {
    258                 this->destroy();
    259             }
    260         }
    261     }
    262    
     258                this->Pickupable::destroy();
     259            }
     260        }
     261    }
     262
    263263    /**
    264264    @brief
     
    271271        PickupCarrier* carrier = this->getCarrier();
    272272        Pawn* pawn = dynamic_cast<Pawn*>(carrier);
    273        
     273
    274274        if(pawn == NULL)
    275275        {
    276276            COUT(1) << "Invalid PickupCarrier in HealthPickup." << std::endl;
    277277        }
    278        
     278
    279279        return pawn;
    280280    }
    281    
     281
    282282    /**
    283283    @brief
     
    290290        if(item == NULL)
    291291            item = new HealthPickup(this);
    292        
     292
    293293        SUPER(HealthPickup, clone, item);
    294        
     294
    295295        HealthPickup* pickup = dynamic_cast<HealthPickup*>(item);
    296296        pickup->setHealth(this->getHealth());
    297297        pickup->setHealthRate(this->getHealthRate());
    298298        pickup->setHealthTypeDirect(this->getHealthTypeDirect());
    299        
     299
    300300        pickup->initializeIdentifier();
    301301    }
    302    
     302
    303303    /**
    304304    @brief
     
    322322        }
    323323    }
    324    
     324
    325325    /**
    326326    @brief
     
    341341        }
    342342    }
    343    
     343
    344344    /**
    345345    @brief
     
    356356        else
    357357        {
    358             COUT(1) << "Invalid healthSpeed in HealthPickup." << std::endl; 
    359         }
    360     }
    361    
     358            COUT(1) << "Invalid healthSpeed in HealthPickup." << std::endl;
     359        }
     360    }
     361
    362362    /**
    363363    @brief
  • code/trunk/src/modules/pickup/items/HealthPickup.h

    r6709 r7163  
    4545
    4646namespace orxonox {
    47    
     47
    4848    //! Enum for the type of the HealthPickup
    4949    namespace pickupHealthType
     
    5656        };
    5757    }
    58    
     58
    5959    /**
    6060    @brief
     
    7171    {
    7272        public:
    73        
     73
    7474            HealthPickup(BaseObject* creator); //!< Constructor.
    7575            virtual ~HealthPickup(); //!< Destructor.
    76            
     76
    7777            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
    7878            virtual void tick(float dt); //!< Is called every tick.
    79            
     79
    8080            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
    8181            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    82            
     82
    8383            /**
    8484            @brief Get the health that is transfered to the Pawn upon usage of this pickup.
     
    9393            inline float getHealthRate(void)
    9494                { return this->healthRate_; }
    95                
     95
    9696            /**
    9797            @brief Get the type of HealthPickup, this pickup is.
    98             @return Returns the health type as an enum. 
     98            @return Returns the health type as an enum.
    9999            */
    100100            inline pickupHealthType::Value getHealthTypeDirect(void)
    101101                { return this->healthType_; }
    102102            const std::string& getHealthType(void); //!< Get the health type of this pickup.
    103            
     103
    104104        protected:
    105105            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
     
    107107            void setHealth(float health); //!< Sets the health.
    108108            void setHealthRate(float speed); //!< Set the rate at which health is transferred if the pickup is continuous.
    109            
     109
    110110            /**
    111111            @brief Set the health type of this pickup.
     
    115115                { this->healthType_ = type; }
    116116            void setHealthType(std::string type); //!< Set the type of the HealthPickup.
    117        
     117
    118118        private:
    119119            void initialize(void); //!< Initializes the member variables.
    120120            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
    121            
     121
    122122            float health_; //!< The health that is transferred to the Pawn.
    123123            float healthRate_; //!< The rate at which the health is transferred.
     
    125125            float maxHealthOverwrite_; //!< Helper to remember with which value we overwrote the maxHealh, to detect if someone else changed it as well.
    126126            pickupHealthType::Value healthType_; //!< The type of the HealthPickup.
    127            
     127
    128128            //! Strings for the health types.
    129129            static const std::string healthTypeLimited_s;
    130130            static const std::string healthTypeTemporary_s;
    131131            static const std::string healthTypePermanent_s;
    132        
     132
    133133    };
    134134}
  • code/trunk/src/modules/pickup/items/InvisiblePickup.cc

    • Property svn:eol-style set to native
    r6755 r7163  
    3434#include "InvisiblePickup.h"
    3535
     36#include <sstream>
     37#include <OgreEntity.h>
     38#include <OgreAnimationState.h>
     39
     40#include "util/StringUtils.h"
    3641#include "core/CoreIncludes.h"
    3742#include "core/XMLPort.h"
    38 #include "util/StringUtils.h"
    3943
    4044#include "worldentities/pawns/Pawn.h"
    4145#include "pickup/PickupIdentifier.h"
    4246
    43 #include <sstream>
    44 
    4547namespace orxonox
    4648{
    4749
    4850    CreateFactory(InvisiblePickup);
    49    
     51
    5052    /**
    5153    @brief
     
    5658        RegisterObject(InvisiblePickup);
    5759        //! Defines who is allowed to pick up the pickup.
    58         this->initialize(); 
    59     }
    60    
     60        this->initialize();
     61    }
     62
    6163    /**
    6264    @brief
     
    6466    */
    6567    InvisiblePickup::~InvisiblePickup()
    66     {       
    67     }
    68    
    69    
     68    {
     69    }
     70
     71
    7072    void InvisiblePickup::initializeIdentifier(void)
    7173    {
     
    7678        this->pickupIdentifier_->addParameter(type1, val1);
    7779    }
    78    
     80
    7981    /**
    8082    @brief
     
    9395    void InvisiblePickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
    9496    {
    95         SUPER(InvisiblePickup, XMLPort, xmlelement, mode);   
     97        SUPER(InvisiblePickup, XMLPort, xmlelement, mode);
    9698        XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode);
    97        
     99
    98100        this->initializeIdentifier();
    99101    }
    100    
     102
    101103    /**
    102104    @brief
     
    106108    {
    107109        SUPER(InvisiblePickup, changedUsed);
    108        
     110
    109111        //! If the pickup is not picked up nothing must be done.
    110112        if(!this->isPickedUp())
    111113            return;
    112        
     114
    113115        if (this->isUsed())
    114116        {
     
    121123                this->startPickupTimer(this->getDuration());
    122124            }
     125
    123126            this->setInvisible(true);
     127
    124128        }
    125129        else
    126130        {
    127131            this->setInvisible(false);
    128        
     132
    129133            if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
    130134            {
    131                 this->destroy();
     135                this->Pickupable::destroy();
    132136            }
    133137            else
     
    136140            }
    137141        }
    138        
    139     }
    140    
     142
     143    }
     144
    141145    /**
    142146    @brief
     
    149153        PickupCarrier* carrier = this->getCarrier();
    150154        Pawn* pawn = dynamic_cast<Pawn*>(carrier);
    151        
     155
    152156        if(pawn == NULL)
    153157        {
     
    156160        return pawn;
    157161    }
    158    
     162
    159163    /**
    160164    @brief
     
    167171        if(item == NULL)
    168172            item = new InvisiblePickup(this);
    169        
     173
    170174        SUPER(InvisiblePickup, clone, item);
    171        
     175
    172176        InvisiblePickup* pickup = dynamic_cast<InvisiblePickup*>(item);
    173177        pickup->setDuration(this->getDuration());
    174178        pickup->initializeIdentifier();
    175179    }
    176    
     180
    177181    /**
    178182    @brief
     
    186190        if(pawn == NULL)
    187191            return false;
    188        
     192
    189193        pawn->setVisible(!invisibility);
     194        pawn->setRadarVisibility(!invisibility);
     195
     196// Test to change Material at runtime!
     197
     198//      Ogre::MaterialPtr mat = this->mesh_.getEntity()->getSubEntity(0)->getMaterial();
     199//      mat->setDiffuse(0.4, 0.3, 0.1, 0.1);
     200//      mat->setAmbient(0.3, 0.7, 0.8);
     201//      mat->setSpecular(0.5, 0.5, 0.5, 0.1);
     202//      Ogre::SceneBlendType sbt = Ogre::SBT_ADD;
     203//
     204//      mat->setSceneBlending(sbt);
     205
    190206        return true;
    191207    }
    192    
     208
    193209    /**
    194210    @brief
     
    209225        }
    210226    }
    211    
     227
    212228    void InvisiblePickup::pickupTimerCallback(void)
    213229    {
  • code/trunk/src/modules/pickup/items/InvisiblePickup.h

    • Property svn:eol-style set to native
    r6710 r7163  
    3838
    3939#include <string>
     40
    4041#include <worldentities/pawns/Pawn.h>
    4142#include "worldentities/StaticEntity.h"
    42 
    4343#include "pickup/Pickup.h"
    4444
    4545namespace orxonox {
    46        
     46
    4747    /**
    4848    @brief
     
    5757    {
    5858        public:
    59        
     59
    6060            InvisiblePickup(BaseObject* creator); //!< Constructor.
    6161            virtual ~InvisiblePickup(); //!< Destructor.
     
    6363            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
    6464            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    65            
     65
    6666            /**
    6767            @brief Checks whether the Pawn is invisible.
     
    7272            inline float getDuration()
    7373                { return this->duration_; }
    74  
     74
    7575        protected:
    7676            bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again.
     
    7878            void initializeIdentifier(void);
    7979            virtual void pickupTimerCallback(void); //!< Function that gets called when the timer ends.
    80        
     80
    8181        private:
    8282            void initialize(void); //!< Initializes the member variables.
  • code/trunk/src/modules/pickup/items/MetaPickup.cc

    r6709 r7163  
    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"
     
    4041
    4142namespace orxonox {
    42  
     43
    4344    CreateFactory(MetaPickup);
    44    
     45
    4546    //! Setting the static variables to their values.
    4647    /*static*/ const std::string MetaPickup::metaTypeNone_s = "none";
    4748    /*static*/ const std::string MetaPickup::metaTypeUse_s = "use";
    4849    /*static*/ const std::string MetaPickup::metaTypeDrop_s = "drop";
    49    
     50    /*static*/ const std::string MetaPickup::metaTypeDestroy_s = "destroy";
     51    /*static*/ const std::string MetaPickup::metaTypeDestroyCarrier_s = "destroyCarrier";
     52
    5053    /**
    5154    @brief
     
    5558    {
    5659        RegisterObject(MetaPickup);
    57        
     60
    5861        this->initialize();
    5962    }
    60    
     63
    6164    /**
    6265    @brief
     
    6568    MetaPickup::~MetaPickup()
    6669    {
    67        
    68     }
    69    
     70
     71    }
     72
    7073    /**
    7174    @brief
     
    7578    {
    7679        this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier());
    77        
     80
    7881        this->setActivationTypeDirect(pickupActivationType::immediate);
    7982        this->setDurationTypeDirect(pickupDurationType::once);
    8083        this->metaType_ = pickupMetaType::none;
    8184    }
    82    
     85
    8386    /**
    8487    @brief
     
    9194        this->pickupIdentifier_->addParameter(type, val);
    9295    }
    93    
     96
    9497    /**
    9598    @brief
     
    99102    {
    100103        SUPER(MetaPickup, XMLPort, xmlelement, mode);
    101        
     104
    102105        XMLPortParam(MetaPickup, "metaType", setMetaType, getMetaType, xmlelement, mode);
    103        
     106
    104107        this->initializeIdentifier();
    105108    }
    106    
     109
    107110    /**
    108111    @brief
     
    113116    {
    114117        SUPER(MetaPickup, changedUsed);
    115        
     118
    116119        //! If the MetaPickup transited to used.
    117120        if(this->isUsed())
     
    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                             carrier->drop(pickup);
     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();
    144         }
    145     }
    146        
     159            this->Pickupable::destroy();
     160        }
     161    }
     162
    147163    /**
    148164    @brief
     
    155171        if(item == NULL)
    156172            item = new MetaPickup(this);
    157        
     173
    158174        SUPER(MetaPickup, clone, item);
    159        
     175
    160176        MetaPickup* pickup = dynamic_cast<MetaPickup*>(item);
    161177        pickup->setMetaTypeDirect(this->getMetaTypeDirect());
    162        
     178
    163179        pickup->initializeIdentifier();
    164180    }
    165    
     181
    166182    /**
    167183    @brief
     
    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;
    184204        }
    185205    }
    186    
     206
    187207    /**
    188208    @brief
     
    205225            this->setMetaTypeDirect(pickupMetaType::drop);
    206226        }
    207     }
    208    
     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;
     237    }
     238
    209239}
  • code/trunk/src/modules/pickup/items/MetaPickup.h

    r6709 r7163  
    4848            none,
    4949            use,
    50             drop
     50            drop,
     51            destroy,
     52            destroyCarrier
    5153        };
    5254    }
    53    
     55
    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
     
    6066    class _PickupExport MetaPickup : public Pickup
    6167    {
    62        
     68
    6369        public:
    6470            MetaPickup(BaseObject* creator); //!< Constructor. Registers and initializes the object.
    6571            virtual ~MetaPickup(); //!< Destructor.
    66            
     72
    6773            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a MetaPickup object through XML.
    68            
     74
    6975            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
    7076            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    71            
     77
    7278            /**
    7379            @brief Returns the meta type of the MetaPickup.
     
    7783                { return this->metaType_; }
    7884            const std::string& getMetaType(void); //!< Get the meta type of this MetaPickup.
    79            
     85
    8086        protected:
    8187            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    82            
     88
    8389            /**
    8490            @brief Set the meta type of the MetaPickup.
     
    8894                { this->metaType_ =  type; }
    8995            void setMetaType(const std::string& type); //!< Set the meta type of this MetaPickup.
    90            
     96
    9197        private:
    9298            void initialize(void); //!< Initializes the member variables.
    93            
     99
    94100            pickupMetaType::Value metaType_; //!< The meta type of the MetaPickup, determines which actions are taken.
    95            
     101
    96102            //! Static strings for the meta types.
    97103            static const std::string metaTypeNone_s;
    98104            static const std::string metaTypeUse_s;
    99105            static const std::string metaTypeDrop_s;
    100            
    101        
     106            static const std::string metaTypeDestroy_s;
     107            static const std::string metaTypeDestroyCarrier_s;
     108
     109
    102110    };
    103111
  • code/trunk/src/modules/pickup/items/SpeedPickup.cc

    r6755 r7163  
    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();
    139        
     138            this->Pickupable::destroy();
     139
    140140        //! If the pickup has transited to used.
    141141        if(this->isUsed())
     
    156156            engine->setSpeedAdd(0.0f);
    157157            engine->setSpeedMultiply(1.0f);
    158            
     158
    159159            if(this->isOnce())
    160160            {
    161161                if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
    162162                {
    163                     this->destroy();
     163                    this->Pickupable::destroy();
    164164                }
    165165                else
     
    186186            COUT(1) << "Invalid PickupCarrier in SpeedPickup." << std::endl;
    187187        }
    188        
     188
    189189        return engine;
    190190    }
     
    269269
    270270    void SpeedPickup::pickupTimerCallback(void)
    271     {       
     271    {
    272272        this->setUsed(false);
    273273    }
  • code/trunk/src/modules/pickup/items/SpeedPickup.h

    r6709 r7163  
    7878        protected:
    7979            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    80            
     80
    8181            virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.
    8282
Note: See TracChangeset for help on using the changeset viewer.