Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 15, 2010, 7:33:11 AM (14 years ago)
Author:
dafrick
Message:

Added changedPickedUp method to Pickupable to solve a problem in PickupCollection, which, for the most part, works now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc

    r6512 r6521  
    172172       
    173173        COUT(4) << "Pickupable (&" << this << ") got picked up by a PickupCarrier (&" << carrier << ")." << std::endl;
     174        this->setCarrier(carrier);
    174175        this->setPickedUp(true);
    175         this->setCarrier(carrier);
     176        return true;
     177    }
     178   
     179    /**
     180    @brief
     181        Helper method to set the Pickupable to either picked up or not picked up.
     182    @param pickedUp
     183        The value this->pickedUp_ should be set to.
     184    @return
     185        Returns true if the pickedUp status was changed, false if not.
     186    */
     187    bool Pickupable::setPickedUp(bool pickedUp)
     188    {
     189        if(this->pickedUp_ == pickedUp)
     190            return false;
     191       
     192        COUT(4) << "Pickupable (&" << this << ") set to pickedUp " << pickedUp << "." << std::endl;
     193       
     194        this->pickedUp_ = pickedUp;
     195        this->changedPickedUp();
     196        return true;
     197    }
     198       
     199    /**
     200    @brief
     201        Sets the carrier of the pickup.
     202    @param carrier
     203        Sets the input PickupCarrier as the carrier of the pickup.
     204    */
     205    inline bool Pickupable::setCarrier(PickupCarrier* carrier)
     206    {
     207        if(this->carrier_ == carrier)
     208            return false;
     209       
     210        COUT(4) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << std::endl;
     211       
     212        this->carrier_ = carrier;
     213        this->changedCarrier();
    176214        return true;
    177215    }
     
    205243    }
    206244   
    207        
    208     /**
    209     @brief
    210         Sets the carrier of the pickup.
    211     @param carrier
    212         Sets the input PickupCarrier as the carrier of the pickup.
    213     @return
    214         Returns true if the carrier was changed, false if not.
    215     */
    216     bool Pickupable::setCarrier(PickupCarrier* carrier)
    217     {
    218         if(this->getCarrier() == carrier)
    219             return false;
    220        
    221         this->carrier_ = carrier;
    222         this->changedCarrier();
    223         return true;
    224     }
    225    
    226245    /**
    227246    @brief
     
    230249        Returns the clone of this pickup as a pointer to a Pickupable.
    231250    */
    232     //TODO: Does this work?
    233251    Pickupable* Pickupable::clone(void)
    234252    {
Note: See TracChangeset for help on using the changeset viewer.