Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2012, 11:08:17 PM (12 years ago)
Author:
landauf
Message:

merged branch presentation2012merge back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/pickup/CollectiblePickup.cc

    r7494 r9348  
    4545        Registers the object and initializes variables.
    4646    */
    47     CollectiblePickup::CollectiblePickup() : isInCollection_(false)
     47    CollectiblePickup::CollectiblePickup() : collection_(NULL)
    4848    {
    4949        RegisterObject(CollectiblePickup);
    50 
    51         this->collection_ = NULL;
    5250    }
    5351
     
    5856    CollectiblePickup::~CollectiblePickup()
    5957    {
    60 
    61     }
    62 
    63     /**
    64     @brief
    65         Is called by OrxonoxClass::destroy() before the object is actually destroyed.
    66     */
    67     void CollectiblePickup::preDestroy(void)
    68     {
    69         this->Pickupable::preDestroy();
    70 
    71         // The PickupCollection has to be destroyed as well.
    72         if(this->isInCollection())
    73             this->collection_->Pickupable::destroy();
    74     }
    75 
    76     /**
    77     @brief
    78         Destroys a Pickupable.
    79     */
    80     void CollectiblePickup::destroyPickup(void)
    81     {
    82         if(!this->isInCollection()) // If the CollectiblePickup is not in a PickupCollection the destroyPickup method of Pickupable is called.
    83             this->Pickupable::destroyPickup();
    84         else // Else the ColectiblePickup is dropped and disabled,
    85         {
    86             this->drop(false);
    87             if(this->isInCollection() && this->isEnabled()) // It is only disabled if it is enabled and still ina PickupCollection after having been dropped.
    88             {
    89                 this->setDisabled();
    90                 this->collection_->pickupDisabled();
    91             }
    92         }
    93     }
    94 
    95     /**
    96     @brief
    97         Is called by the PickupCarrier when it is being destroyed.
    98     */
    99     void CollectiblePickup::carrierDestroyed(void)
    100     {
    101         if(!this->isInCollection())
    102             this->Pickupable::destroy();
    103         else // If the CollectiblePickup is part of a PickupCollection it is just dropped instead of destroyed.
    104             this->drop(false);
     58        if (this->isInCollection())
     59            this->collection_->removePickupable(this);
    10560    }
    10661
     
    13186    /**
    13287    @brief
    133         Adds this CollectiblePickup to the input PickupCollection.
     88        Notifies this CollectiblePickup that it was added to a PickupCollection.
    13489    @param collection
    13590        A pointer to the PickupCollection to which the CollectiblePickup should be added.
    136     @return
    137         Returns true if the CollectiblePickup was successfully added to the PickupCollection.
    13891    */
    139     bool CollectiblePickup::addToCollection(PickupCollection* collection)
     92    void CollectiblePickup::wasAddedToCollection(PickupCollection* collection)
    14093    {
    141         if(this->isInCollection() || collection == NULL) //If the CollectiblePickup already is in a PickupCollection or if the input pointer is NULL.
    142             return false;
    143 
    144         this->isInCollection_ = true;
    14594        this->collection_ = collection;
    146         return true;
    14795    }
    14896
    14997    /**
    15098    @brief
    151         Removes this CollectiblePickup from its PickupCollection.
    152     @return
    153         Returns true if the CollectiblePickup was succcessfully removed.
     99        Notifies this CollectiblePickup that it was removed from its PickupCollection.
    154100    */
    155     bool CollectiblePickup::removeFromCollection(void)
     101    void CollectiblePickup::wasRemovedFromCollection(void)
    156102    {
    157         if(!this->isInCollection()) //If the CollectiblePickup is not in a PickupCollection.
    158             return false;
    159 
    160         this->isInCollection_ = false;
    161103        this->collection_ = NULL;
    162         return true;
    163104    }
    164 
    165105}
Note: See TracChangeset for help on using the changeset viewer.