[Orxonox-commit 1772] r6490 - in code/branches/pickup3/src: modules/pickup/items orxonox/interfaces

dafrick at orxonox.net dafrick at orxonox.net
Mon Mar 8 09:39:47 CET 2010


Author: dafrick
Date: 2010-03-08 09:39:47 +0100 (Mon, 08 Mar 2010)
New Revision: 6490

Modified:
   code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc
   code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc
   code/branches/pickup3/src/orxonox/interfaces/Pickupable.h
Log:
Added target to HealthPickup, which I had forgotten.


Modified: code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc	2010-03-08 07:09:17 UTC (rev 6489)
+++ code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc	2010-03-08 08:39:47 UTC (rev 6490)
@@ -71,14 +71,14 @@
         Initializes the member variables.
     */
     void HealthPickup::initialize(void)
-    {
-        RegisterObject(HealthPickup);
-        
+    {        
         this->health_ = 0;
         this->healthRate_ = 0;
         this->healthType_ = pickupHealthType::limited;
         this->maxHealthSave_ = 0;
         this->maxHealthOverwrite_ = 0;
+        
+        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
     }
     
     /**

Modified: code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc
===================================================================
--- code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc	2010-03-08 07:09:17 UTC (rev 6489)
+++ code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc	2010-03-08 08:39:47 UTC (rev 6490)
@@ -103,16 +103,28 @@
     */
     bool Pickupable::isTarget(const PickupCarrier* carrier) const
     {
-        Identifier* identifier = carrier->getIdentifier();
+        return this->isTarget(carrier->getIdentifier());
+    }
+    
+    /**
+    @brief
+        Get whether a given class, represented by the input Identifier, is a target of this pickup.
+    @param target
+        The Identifier of which it has to be determinde whether it is a target of this pickup.
+    @return
+        Returns true if the given Identifier is a target.
+    */
+    bool Pickupable::isTarget(Identifier* target) const
+    {
         //! Iterate through all targets of this Pickupable.
         for(std::list<Identifier*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)
         {
-            if(identifier->isA(*it))
+            if(target->isA(*it))
                 return true;
         }
         return false;
     }
-    
+        
     /**
     @brief
         Add a PickupCarrier as target of this pickup.
@@ -123,11 +135,24 @@
     */
     bool Pickupable::addTarget(PickupCarrier* target)
     {
+        return this->addTarget(target->getIdentifier());
+    }
+    
+    /**
+    @brief
+        Add a class, representetd by the input Identifier, as target of this pickup.
+    @param target
+        The Identifier to be added.
+    @return
+        Returns true if the target was added, false if not.
+    */
+    bool Pickupable::addTarget(Identifier* target)
+    {
         if(this->isTarget(target)) //!< If the input target is already present in the list of targets.
             return false;
         
-        COUT(4) << "Target (&" << target << ") added to Pickupable (&" << this << ")." << std::endl;
-        this->targets_.push_back(target->getIdentifier());
+        COUT(4) << "Target " << target->getName() << " added to Pickupable (&" << this << ")." << std::endl;
+        this->targets_.push_back(target);
         return true;
     }
     

Modified: code/branches/pickup3/src/orxonox/interfaces/Pickupable.h
===================================================================
--- code/branches/pickup3/src/orxonox/interfaces/Pickupable.h	2010-03-08 07:09:17 UTC (rev 6489)
+++ code/branches/pickup3/src/orxonox/interfaces/Pickupable.h	2010-03-08 08:39:47 UTC (rev 6490)
@@ -82,7 +82,9 @@
             bool dropped(void); //!< Sets the Pickupable to not picked up or dropped.
             
             bool isTarget(const PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this pickup.
+            bool isTarget(Identifier* identifier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this pickup.
             bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this pickup.
+            bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this pickup.
             
             /**
             @brief Get the carrier of the pickup.




More information about the Orxonox-commit mailing list