Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6490


Ignore:
Timestamp:
Mar 8, 2010, 9:39:47 AM (14 years ago)
Author:
dafrick
Message:

Added target to HealthPickup, which I had forgotten.

Location:
code/branches/pickup3/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc

    r6484 r6490  
    7272    */
    7373    void HealthPickup::initialize(void)
    74     {
    75         RegisterObject(HealthPickup);
    76        
     74    {       
    7775        this->health_ = 0;
    7876        this->healthRate_ = 0;
     
    8078        this->maxHealthSave_ = 0;
    8179        this->maxHealthOverwrite_ = 0;
     80       
     81        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
    8282    }
    8383   
  • code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc

    r6480 r6490  
    104104    bool Pickupable::isTarget(const PickupCarrier* carrier) const
    105105    {
    106         Identifier* identifier = carrier->getIdentifier();
     106        return this->isTarget(carrier->getIdentifier());
     107    }
     108   
     109    /**
     110    @brief
     111        Get whether a given class, represented by the input Identifier, is a target of this pickup.
     112    @param target
     113        The Identifier of which it has to be determinde whether it is a target of this pickup.
     114    @return
     115        Returns true if the given Identifier is a target.
     116    */
     117    bool Pickupable::isTarget(Identifier* target) const
     118    {
    107119        //! Iterate through all targets of this Pickupable.
    108120        for(std::list<Identifier*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)
    109121        {
    110             if(identifier->isA(*it))
     122            if(target->isA(*it))
    111123                return true;
    112124        }
    113125        return false;
    114126    }
    115    
     127       
    116128    /**
    117129    @brief
     
    124136    bool Pickupable::addTarget(PickupCarrier* target)
    125137    {
     138        return this->addTarget(target->getIdentifier());
     139    }
     140   
     141    /**
     142    @brief
     143        Add a class, representetd by the input Identifier, as target of this pickup.
     144    @param target
     145        The Identifier to be added.
     146    @return
     147        Returns true if the target was added, false if not.
     148    */
     149    bool Pickupable::addTarget(Identifier* target)
     150    {
    126151        if(this->isTarget(target)) //!< If the input target is already present in the list of targets.
    127152            return false;
    128153       
    129         COUT(4) << "Target (&" << target << ") added to Pickupable (&" << this << ")." << std::endl;
    130         this->targets_.push_back(target->getIdentifier());
     154        COUT(4) << "Target " << target->getName() << " added to Pickupable (&" << this << ")." << std::endl;
     155        this->targets_.push_back(target);
    131156        return true;
    132157    }
  • code/branches/pickup3/src/orxonox/interfaces/Pickupable.h

    r6475 r6490  
    8383           
    8484            bool isTarget(const PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this pickup.
     85            bool isTarget(Identifier* identifier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this pickup.
    8586            bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this pickup.
     87            bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this pickup.
    8688           
    8789            /**
Note: See TracChangeset for help on using the changeset viewer.