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:
16 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r8706 r9348  
    77  ShieldPickup.cc
    88  ShrinkPickup.cc
     9  DamageBoostPickup.cc
    910)
  • code/trunk/src/modules/pickup/items/DronePickup.cc

    r8858 r9348  
    3939
    4040#include "controllers/DroneController.h"
    41 #include "pickup/PickupIdentifier.h"
    4241#include "worldentities/Drone.h"
    4342#include "worldentities/pawns/Pawn.h"
     
    7574    {
    7675        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
    77         this->setDurationTypeDirect(pickupDurationType::once);
     76        this->setDurationType(pickupDurationType::once);
    7877        this->droneTemplate_ = "";
    79     }
    80 
    81     /**
    82     @brief
    83         Initializes the PickupIdentifier of this pickup.
    84     */
    85     void DronePickup::initializeIdentifier(void)
    86     {
    87         std::string val = this->getDroneTemplate();
    88         std::string type = "droneTemplate";
    89         this->pickupIdentifier_->addParameter(type, val);
    9078    }
    9179
     
    9886        SUPER(DronePickup, XMLPort, xmlelement, mode);
    9987        XMLPortParam(DronePickup, "droneTemplate", setDroneTemplate, getDroneTemplate, xmlelement, mode);
    100 
    101         this->initializeIdentifier();
    10288    }
    10389
     
    10894        The name of the Template to e set.
    10995    */
    110     void DronePickup::setDroneTemplate(std::string templatename){
     96    void DronePickup::setDroneTemplate(const std::string& templatename){
    11197        droneTemplate_ = templatename;
    11298    }
     
    144130
    145131                Controller* controller = drone->getController();
    146                 DroneController* droneController = dynamic_cast<DroneController*>(controller);
     132                DroneController* droneController = orxonox_cast<DroneController*>(controller);
    147133                if(droneController != NULL)
    148134                {
     
    175161    {
    176162        PickupCarrier* carrier = this->getCarrier();
    177         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     163        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    178164
    179165        if(pawn == NULL)
     
    184170        return pawn;
    185171    }
    186 
    187     /**
    188     @brief
    189         Creates a duplicate of the input OrxonoxClass.
    190     @param item
    191         A pointer to the Orxonox class.
    192     */
    193     void DronePickup::clone(OrxonoxClass*& item)
    194     {
    195         if(item == NULL)
    196             item = new DronePickup(this);
    197 
    198         SUPER(DronePickup, clone, item);
    199 
    200         DronePickup* pickup = dynamic_cast<DronePickup*>(item);
    201         pickup->setDroneTemplate(this->getDroneTemplate());
    202 
    203         pickup->initializeIdentifier();
    204     }
    205172}
  • code/trunk/src/modules/pickup/items/DronePickup.h

    r7547 r9348  
    7070
    7171            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
    72             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    7372
    7473            const std::string& getDroneTemplate() const; //!< Get the name of the droneTemplate.
    7574
    7675        protected:
    77             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    78 
    79             void setDroneTemplate(std::string templatename); //!< Set the droneTemplate.
     76            void setDroneTemplate(const std::string& templatename); //!< Set the droneTemplate.
    8077
    8178        private:
  • code/trunk/src/modules/pickup/items/HealthPickup.cc

    r8864 r9348  
    3838#include "core/XMLPort.h"
    3939
    40 #include "pickup/PickupIdentifier.h"
    4140#include "worldentities/pawns/Pawn.h"
    4241
     
    8786    /**
    8887    @brief
    89         Initializes the PickupIdentifier of this pickup.
    90     */
    91     void HealthPickup::initializeIdentifier(void)
    92     {
    93         std::stringstream stream;
    94         stream << this->getHealth();
    95         std::string type1 = "health";
    96         std::string val1 = stream.str();
    97         this->pickupIdentifier_->addParameter(type1, val1);
    98 
    99         std::string val2 = this->getHealthType();
    100         std::string type2 = "healthType";
    101         this->pickupIdentifier_->addParameter(type2, val2);
    102 
    103         stream.clear();
    104         stream << this->getHealthRate();
    105         std::string val3 = stream.str();
    106         std::string type3 = "healthRate";
    107         this->pickupIdentifier_->addParameter(type3, val3);
    108     }
    109 
    110     /**
    111     @brief
    11288        Method for creating a HealthPickup object through XML.
    11389    */
     
    11894        XMLPortParam(HealthPickup, "health", setHealth, getHealth, xmlelement, mode);
    11995        XMLPortParam(HealthPickup, "healthRate", setHealthRate, getHealthRate, xmlelement, mode);
    120         XMLPortParam(HealthPickup, "healthType", setHealthType, getHealthType, xmlelement, mode);
     96        XMLPortParam(HealthPickup, "healthType", setHealthTypeAsString, getHealthTypeAsString, xmlelement, mode);
    12197
    12298        if(!this->isContinuous())
    123             this->healthRate_ = 0.0f;
    124 
    125         this->initializeIdentifier();
     99            this->setHealthRate(0.0f); // TODO: this logic should be inside tick(), not in XMLPort
    126100    }
    127101
     
    151125            this->setHealth(this->getHealth()-health);
    152126
    153             switch(this->getHealthTypeDirect())
     127            switch(this->getHealthType())
    154128            {
    155129                case pickupHealthType::permanent:
     
    198172
    199173                float health = 0.0f;
    200                 switch(this->getHealthTypeDirect())
     174                switch(this->getHealthType())
    201175                {
    202176                    case pickupHealthType::permanent:
     
    227201        else
    228202        {
    229             if(this->getHealthTypeDirect() == pickupHealthType::temporary)
     203            if(this->getHealthType() == pickupHealthType::temporary)
    230204            {
    231205                PickupCarrier* carrier = this->getCarrier();
    232                 Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     206                Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    233207
    234208                if(pawn == NULL)
     
    264238    {
    265239        PickupCarrier* carrier = this->getCarrier();
    266         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     240        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    267241
    268242        if(pawn == NULL)
     
    270244
    271245        return pawn;
    272     }
    273 
    274     /**
    275     @brief
    276         Creates a duplicate of the input OrxonoxClass.
    277     @param item
    278         A pointer to the Orxonox class.
    279     */
    280     void HealthPickup::clone(OrxonoxClass*& item)
    281     {
    282         if(item == NULL)
    283             item = new HealthPickup(this);
    284 
    285         SUPER(HealthPickup, clone, item);
    286 
    287         HealthPickup* pickup = dynamic_cast<HealthPickup*>(item);
    288         pickup->setHealth(this->getHealth());
    289         pickup->setHealthRate(this->getHealthRate());
    290         pickup->setHealthTypeDirect(this->getHealthTypeDirect());
    291 
    292         pickup->initializeIdentifier();
    293246    }
    294247
     
    299252        Returns the health type as a string.
    300253    */
    301     const std::string& HealthPickup::getHealthType(void) const
    302     {
    303         switch(this->getHealthTypeDirect())
     254    const std::string& HealthPickup::getHealthTypeAsString(void) const
     255    {
     256        switch(this->getHealthType())
    304257        {
    305258            case pickupHealthType::limited:
     
    352305        The type as a string.
    353306    */
    354     void HealthPickup::setHealthType(std::string type)
     307    void HealthPickup::setHealthTypeAsString(const std::string& type)
    355308    {
    356309        if(type == HealthPickup::healthTypeLimited_s)
    357             this->setHealthTypeDirect(pickupHealthType::limited);
     310            this->setHealthType(pickupHealthType::limited);
    358311        else if(type == HealthPickup::healthTypeTemporary_s)
    359             this->setHealthTypeDirect(pickupHealthType::temporary);
     312            this->setHealthType(pickupHealthType::temporary);
    360313        else if(type == HealthPickup::healthTypePermanent_s)
    361             this->setHealthTypeDirect(pickupHealthType::permanent);
     314            this->setHealthType(pickupHealthType::permanent);
    362315        else
    363316            orxout(internal_error, context::pickups) << "Invalid healthType '" << type << "' in HealthPickup." << endl;
  • code/trunk/src/modules/pickup/items/HealthPickup.h

    r7551 r9348  
    9797
    9898            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
    99             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    10099
    101100            /**
     
    116115            @return Returns the health type as an enum.
    117116            */
    118             inline pickupHealthType::Value getHealthTypeDirect(void) const
     117            inline pickupHealthType::Value getHealthType(void) const
    119118                { return this->healthType_; }
    120             const std::string& getHealthType(void) const; //!< Get the health type of this pickup.
     119            const std::string& getHealthTypeAsString(void) const; //!< Get the health type of this pickup.
    121120
    122121        protected:
    123             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    124 
    125122            void setHealth(float health); //!< Sets the health.
    126123            void setHealthRate(float speed); //!< Set the rate at which health is transferred if the pickup is continuous.
     
    130127            @param type The type of this pickup as an enum.
    131128            */
    132             inline void setHealthTypeDirect(pickupHealthType::Value type)
     129            inline void setHealthType(pickupHealthType::Value type)
    133130                { this->healthType_ = type; }
    134             void setHealthType(std::string type); //!< Set the type of the HealthPickup.
     131            void setHealthTypeAsString(const std::string& type); //!< Set the type of the HealthPickup.
    135132
    136133        private:
  • code/trunk/src/modules/pickup/items/InvisiblePickup.cc

    r8858 r9348  
    4040#include "core/XMLPort.h"
    4141
    42 #include "pickup/PickupIdentifier.h"
    4342#include "worldentities/pawns/Pawn.h"
    4443
     
    7978    /**
    8079    @brief
    81         Initializes the PickupIdentifier of this pickup.
    82     */
    83     void InvisiblePickup::initializeIdentifier(void)
    84     {
    85         std::stringstream stream;
    86         stream << this->getDuration();
    87         std::string type1 = "duration";
    88         std::string val1 = stream.str();
    89         this->pickupIdentifier_->addParameter(type1, val1);
    90     }
    91 
    92     /**
    93     @brief
    9480        Method for creating a HealthPickup object through XML.
    9581    */
     
    9884        SUPER(InvisiblePickup, XMLPort, xmlelement, mode);
    9985        XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode);
    100 
    101         this->initializeIdentifier();
    10286    }
    10387
     
    148132    /**
    149133    @brief
    150         Creates a duplicate of the input OrxonoxClass.
    151     @param item
    152         A pointer to the Orxonox class.
    153     */
    154     void InvisiblePickup::clone(OrxonoxClass*& item)
    155     {
    156         if(item == NULL)
    157             item = new InvisiblePickup(this);
    158 
    159         SUPER(InvisiblePickup, clone, item);
    160 
    161         InvisiblePickup* pickup = dynamic_cast<InvisiblePickup*>(item);
    162         pickup->setDuration(this->getDuration());
    163         pickup->initializeIdentifier();
    164     }
    165 
    166     /**
    167     @brief
    168134        Sets the invisibility.
    169135    @param invisibility
     
    202168    {
    203169        PickupCarrier* carrier = this->getCarrier();
    204         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     170        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    205171
    206172        if(pawn == NULL)
  • code/trunk/src/modules/pickup/items/InvisiblePickup.h

    r7547 r9348  
    7272            InvisiblePickup(BaseObject* creator); //!< Constructor.
    7373            virtual ~InvisiblePickup(); //!< Destructor.
    74            
     74
    7575            virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
    7676            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
    77             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    7877
    7978            /**
     
    9190
    9291        protected:
    93             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    94 
    9592            bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again.
    9693            void setDuration(float duration); //!< Sets the time the InvisibilityPickup will last.
  • code/trunk/src/modules/pickup/items/MetaPickup.cc

    r8858 r9348  
    3636
    3737#include "interfaces/PickupCarrier.h"
    38 #include "pickup/PickupIdentifier.h"
    3938#include "worldentities/pawns/Pawn.h"
    4039
     
    8079        this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier());
    8180
    82         this->setDurationTypeDirect(pickupDurationType::once);
     81        this->setDurationType(pickupDurationType::once);
    8382        this->metaType_ = pickupMetaType::none;
    8483    }
     
    8685    /**
    8786    @brief
    88         Helper method to initialize the PickupIdentifier.
    89     */
    90     void MetaPickup::initializeIdentifier(void)
    91     {
    92         std::string val = this->getMetaType();
    93         std::string type = "metaType";
    94         this->pickupIdentifier_->addParameter(type, val);
    95     }
    96 
    97     /**
    98     @brief
    9987        Method for creating a MetaPickup object through XML.
    10088    */
     
    10391        SUPER(MetaPickup, XMLPort, xmlelement, mode);
    10492
    105         XMLPortParam(MetaPickup, "metaType", setMetaType, getMetaType, xmlelement, mode);
    106 
    107         this->initializeIdentifier();
     93        XMLPortParam(MetaPickup, "metaType", setMetaTypeAsString, getMetaTypeAsString, xmlelement, mode);
    10894    }
    10995
     
    121107        {
    122108            PickupCarrier* carrier = this->getCarrier();
    123             if(this->getMetaTypeDirect() != pickupMetaType::none && carrier != NULL)
     109            if(this->getMetaType() != pickupMetaType::none && carrier != NULL)
    124110            {
    125111                // If the metaType is destroyCarrier, then the PickupCarrier is destroyed.
    126                 if(this->getMetaTypeDirect() == pickupMetaType::destroyCarrier)
     112                if(this->getMetaType() == pickupMetaType::destroyCarrier)
    127113                {
    128114                    Pawn* pawn = orxonox_cast<Pawn*>(carrier);
     
    139125
    140126                    // If the metaType is use, then the Pickupable is set to used.
    141                     if(this->getMetaTypeDirect() == pickupMetaType::use && !pickup->isUsed())
     127                    if(this->getMetaType() == pickupMetaType::use && !pickup->isUsed())
    142128                    {
    143129                        pickup->setUsed(true);
    144130                    }
    145131                    // If the metaType is drop, then the Pickupable is dropped.
    146                     else if(this->getMetaTypeDirect() == pickupMetaType::drop)
     132                    else if(this->getMetaType() == pickupMetaType::drop)
    147133                    {
    148134                        pickup->drop();
    149135                    }
    150136                    // If the metaType is destroy, then the Pickupable is destroyed.
    151                     else if(this->getMetaTypeDirect() == pickupMetaType::destroy)
     137                    else if(this->getMetaType() == pickupMetaType::destroy)
    152138                    {
    153139                        pickup->Pickupable::destroy();
     
    161147    /**
    162148    @brief
    163         Creates a duplicate of the input OrxonoxClass.
    164     @param item
    165         A pointer to the Orxonox class.
    166     */
    167     void MetaPickup::clone(OrxonoxClass*& item)
    168     {
    169         if(item == NULL)
    170             item = new MetaPickup(this);
    171 
    172         SUPER(MetaPickup, clone, item);
    173 
    174         MetaPickup* pickup = dynamic_cast<MetaPickup*>(item);
    175         pickup->setMetaTypeDirect(this->getMetaTypeDirect());
    176 
    177         pickup->initializeIdentifier();
    178     }
    179 
    180     /**
    181     @brief
    182149        Get the meta type of this MetaPickup.
    183150    @return
    184151        Returns a string with the meta type of the MetaPickup.
    185152    */
    186     const std::string& MetaPickup::getMetaType(void) const
    187     {
    188         switch(this->getMetaTypeDirect())
     153    const std::string& MetaPickup::getMetaTypeAsString(void) const
     154    {
     155        switch(this->getMetaType())
    189156        {
    190157            case pickupMetaType::none:
     
    209176        A string with the type to be set.
    210177    */
    211     void MetaPickup::setMetaType(const std::string& type)
     178    void MetaPickup::setMetaTypeAsString(const std::string& type)
    212179    {
    213180        if(type == MetaPickup::metaTypeNone_s)
    214181        {
    215             this->setMetaTypeDirect(pickupMetaType::none);
     182            this->setMetaType(pickupMetaType::none);
    216183        }
    217184        else if(type == MetaPickup::metaTypeUse_s)
    218185        {
    219             this->setMetaTypeDirect(pickupMetaType::use);
     186            this->setMetaType(pickupMetaType::use);
    220187        }
    221188        else if(type == MetaPickup::metaTypeDrop_s)
    222189        {
    223             this->setMetaTypeDirect(pickupMetaType::drop);
     190            this->setMetaType(pickupMetaType::drop);
    224191        }
    225192        else if(type == MetaPickup::metaTypeDestroy_s)
    226193        {
    227             this->setMetaTypeDirect(pickupMetaType::destroy);
     194            this->setMetaType(pickupMetaType::destroy);
    228195        }
    229196        else if(type == MetaPickup::metaTypeDestroyCarrier_s)
    230197        {
    231             this->setMetaTypeDirect(pickupMetaType::destroyCarrier);
     198            this->setMetaType(pickupMetaType::destroyCarrier);
    232199        }
    233200        else
  • code/trunk/src/modules/pickup/items/MetaPickup.h

    r7547 r9348  
    6969
    7070        The default value is <em>none</em>, which basically does nothing.
    71        
     71
    7272        The parameter <b>activation type</b> can be used to specify, whether the MetaPickup is used upon pickup (<em>immediate</em>) or not (<em>onUse</em>). With <em>immediate</em> being the default.
    7373
     
    9595
    9696            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
    97             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    9897
    9998            /**
     
    101100            @return Returns an enum with the meta type of the MetaPickup.
    102101            */
    103             inline pickupMetaType::Value getMetaTypeDirect(void) const
     102            inline pickupMetaType::Value getMetaType(void) const
    104103                { return this->metaType_; }
    105             const std::string& getMetaType(void) const; //!< Get the meta type of this MetaPickup.
     104            const std::string& getMetaTypeAsString(void) const; //!< Get the meta type of this MetaPickup.
    106105
    107106        protected:
    108             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    109 
    110107            /**
    111108            @brief Set the meta type of the MetaPickup.
    112109            @param type The meta type as an enum.
    113110            */
    114             inline void setMetaTypeDirect(pickupMetaType::Value type)
     111            inline void setMetaType(pickupMetaType::Value type)
    115112                { this->metaType_ =  type; }
    116             void setMetaType(const std::string& type); //!< Set the meta type of this MetaPickup.
     113            void setMetaTypeAsString(const std::string& type); //!< Set the meta type of this MetaPickup.
    117114
    118115        private:
  • code/trunk/src/modules/pickup/items/ShieldPickup.cc

    r8858 r9348  
    3838#include "core/XMLPort.h"
    3939
    40 #include "pickup/PickupIdentifier.h"
    4140#include "worldentities/pawns/Pawn.h"
    4241
     
    8079    /**
    8180    @brief
    82         Initializes the PickupIdentifier of this pickup.
    83     */
    84     void ShieldPickup::initializeIdentifier(void)
    85     {
    86         std::stringstream stream;
    87         stream << this->getDuration();
    88         std::string type1 = "duration";
    89         std::string val1 = stream.str();
    90         this->pickupIdentifier_->addParameter(type1, val1);
    91 
    92         stream.clear();
    93         stream << this->getShieldHealth();
    94         std::string type2 = "ShieldHealth";
    95         std::string val2 = stream.str();
    96         this->pickupIdentifier_->addParameter(type2, val2);
    97 
    98         stream.clear();
    99         stream << this->getShieldAbsorption();
    100         std::string type3 = "ShieldAbsorption";
    101         std::string val3 = stream.str();
    102         this->pickupIdentifier_->addParameter(type3, val3);
    103 
    104     }
    105 
    106     /**
    107     @brief
    10881        Method for creating a ShieldPickup object through XML.
    10982    */
     
    11588        XMLPortParam(ShieldPickup, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode);
    11689        XMLPortParam(ShieldPickup, "duration", setDuration, getDuration, xmlelement, mode);
    117 
    118         this->initializeIdentifier();
    11990    }
    12091
     
    177148    {
    178149        PickupCarrier* carrier = this->getCarrier();
    179         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     150        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    180151
    181152        if(pawn == NULL)
     
    184155        }
    185156        return pawn;
    186     }
    187 
    188     /**
    189     @brief
    190         Creates a duplicate of the input OrxonoxClass.
    191     @param item
    192         A pointer to the Orxonox class.
    193     */
    194     void ShieldPickup::clone(OrxonoxClass*& item)
    195     {
    196         if(item == NULL)
    197             item = new ShieldPickup(this);
    198 
    199         SUPER(ShieldPickup, clone, item);
    200 
    201         ShieldPickup* pickup = dynamic_cast<ShieldPickup*>(item);
    202         pickup->setDuration(this->getDuration());
    203         pickup->setShieldAbsorption(this->getShieldAbsorption());
    204         pickup->setShieldHealth(this->getShieldHealth());
    205         pickup->initializeIdentifier();
    206157    }
    207158
  • code/trunk/src/modules/pickup/items/ShieldPickup.h

    r7547 r9348  
    8282
    8383            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
    84             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    8584
    8685            /**
     
    104103
    105104        protected:
    106             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    107105            void pickupTimerCallback(void); //!< Helper method. Is called by the Timer as soon as it expires.
    108106
  • code/trunk/src/modules/pickup/items/ShrinkPickup.cc

    r8713 r9348  
    4040#include "core/XMLPort.h"
    4141
    42 #include "pickup/PickupIdentifier.h"
    4342#include "worldentities/pawns/Pawn.h"
    4443
     
    8180    }
    8281
    83     void ShrinkPickup::initializeIdentifier(void)
    84     {
    85         std::stringstream stream;
    86         stream << this->getShrinkFactor();
    87         std::string type1 = "shrinkFactor";
    88         std::string val1 = stream.str();
    89         this->pickupIdentifier_->addParameter(type1, val1);
    90 
    91         stream.clear();
    92         stream << this->getDuration();
    93         std::string val2 = stream.str();
    94         std::string type2 = "duration";
    95         this->pickupIdentifier_->addParameter(type2, val2);
    96 
    97         stream.clear();
    98         stream << this->getShrinkDuration();
    99         std::string val3 = stream.str();
    100         std::string type3 = "shrinkDuration";
    101         this->pickupIdentifier_->addParameter(type3, val3);
    102     }
    103 
    10482   /**
    10583    @brief
     
    11391        XMLPortParam(ShrinkPickup, "duration", setDuration, getDuration, xmlelement, mode);
    11492        XMLPortParam(ShrinkPickup, "shrinkDuration", setShrinkDuration, getShrinkDuration, xmlelement, mode);
    115 
    116         this->initializeIdentifier();
     93    }
     94
     95    /**
     96    @brief Sets the shrinking factor.
     97    @param factor The factor, needs to greater than 1.
     98    */
     99    void ShrinkPickup::setShrinkFactor(float factor)
     100    {
     101        if(factor <= 1.0f)
     102        {
     103            orxout(internal_warning, context::pickups) << "Invalid shrinking factor in ShrinkPickup. Ignoring.." << endl;
     104            return;
     105        }
     106        this->shrinkFactor_ = factor;
     107    }
     108
     109    /**
     110    @brief Set the duration for which the ship remains shrunken.
     111    @param duration The duration, needs to be non-negative.
     112    */
     113    void ShrinkPickup::setDuration(float duration)
     114    {
     115        if(duration < 0.0f)
     116        {
     117            orxout(internal_warning, context::pickups) << "Invalid duration in ShrinkPickup. Ignoring.." << endl;
     118            return;
     119        }
     120        this->duration_ = duration;
     121    }
     122
     123    /**
     124    @brief Set the shrink duration.
     125    @param speed The shrink duration, needs to be positive.
     126    */
     127    void ShrinkPickup::setShrinkDuration(float speed)
     128    {
     129        if(speed <= 0.0f)
     130        {
     131            orxout(internal_warning, context::pickups) << "Invalid shrink duration in ShrinkPickup. Ignoring.." << endl;
     132            return;
     133        }
     134        this->shrinkDuration_ = speed;
    117135    }
    118136
     
    148166    {
    149167        SUPER(ShrinkPickup, changedPickedUp);
    150        
     168
    151169        if(!this->isPickedUp() && this->isActive_)
    152170        {
     
    271289
    272290                bool destroy = false;
    273                
     291
    274292                // Stop shrinking if the desired size is reached.
    275293                if(this->timeRemainig_ <= 0.0f)
     
    314332    {
    315333        PickupCarrier* carrier = this->getCarrier();
    316         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     334        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    317335
    318336        return pawn;
    319337    }
    320 
    321     /**
    322     @brief
    323         Creates a duplicate of the input OrxonoxClass.
    324     @param item
    325         A pointer to the Orxonox class.
    326     */
    327     void ShrinkPickup::clone(OrxonoxClass*& item)
    328     {
    329         if(item == NULL)
    330             item = new ShrinkPickup(this);
    331 
    332         SUPER(ShrinkPickup, clone, item);
    333         ShrinkPickup* pickup = dynamic_cast<ShrinkPickup*>(item);
    334         pickup->setShrinkFactor(this->getShrinkFactor());
    335         pickup->setDuration(this->getDuration());
    336         pickup->setShrinkDuration(this->getShrinkDuration());
    337 
    338         pickup->initializeIdentifier();
    339     }
    340338}
  • code/trunk/src/modules/pickup/items/ShrinkPickup.h

    r8858 r9348  
    8080            virtual void changedUsed(void); // Is called when the pickup has transited from used to unused or the other way around.
    8181            virtual void changedPickedUp(void);
    82             virtual void clone(OrxonoxClass*& item); // Creates a duplicate of the input OrxonoxClass.
    8382
    8483            /**
     
    8887            inline float getShrinkFactor(void) const
    8988                { return this->shrinkFactor_; }
    90             /**
    91             @brief Sets the shrinking factor.
    92             @param factor The factor, needs to greater than 1.
    93             */
    94             inline void setShrinkFactor(float factor)
    95                 { if(factor <= 1.0f) { orxout(internal_warning, context::pickups) << "Invalid shrinking factor in ShrinkPickup. Ignoring.." << endl; return; } this->shrinkFactor_ = factor; }
     89            void setShrinkFactor(float factor);
     90
    9691            /**
    9792            @brief Get the duration for which the ship remains shrunken.
     
    10095            inline float getDuration(void) const
    10196                { return this->duration_; }
    102             /**
    103             @brief Set the duration for which the ship remains shrunken.
    104             @param duration The duration, needs to be non-negative.
    105             */
    106             inline void setDuration(float duration)
    107                 { if(duration < 0.0f) { orxout(internal_warning, context::pickups) << "Invalid duration in ShrinkPickup. Ignoring.." << endl; return; } this->duration_ = duration; }
     97            void setDuration(float duration);
     98
    10899            /**
    109100            @brief Get the shrink speed.
     
    112103            inline float getShrinkDuration(void) const
    113104                { return this->shrinkDuration_; }
    114             /**
    115             @brief Set the shrink duration.
    116             @param speed The shrink duration, needs to be positive.
    117             */
    118             inline void setShrinkDuration(float speed)
    119                 { if(speed <= 0.0f) { orxout(internal_warning, context::pickups) << "Invalid shrink duration in ShrinkPickup. Ignoring.." << endl; return; } this->shrinkDuration_ = speed; }
    120 
    121         protected:
    122             void initializeIdentifier(void);
     105            void setShrinkDuration(float speed);
    123106
    124107        private:
     
    135118            float currentFactor_;       //!< The shrink factor that is currently applied.
    136119            float timeRemainig_;        //!< The remaining shrink time.
    137            
     120
    138121            Pawn* carrierToPawnHelper(void);
    139122            Timer durationTimer_;
  • code/trunk/src/modules/pickup/items/SpeedPickup.cc

    r8858 r9348  
    3838#include "core/XMLPort.h"
    3939
    40 #include "pickup/PickupIdentifier.h"
    4140#include "worldentities/pawns/SpaceShip.h"
    4241
     
    8079    /**
    8180    @brief
    82         Initializes the PickupIdentifier of this pickup.
    83     */
    84     void SpeedPickup::initializeIdentifier(void)
    85     {
    86         std::stringstream stream;
    87         stream << this->getDuration();
    88         std::string type1 = "duration";
    89         std::string val1 = stream.str();
    90         this->pickupIdentifier_->addParameter(type1, val1);
    91 
    92         stream.clear();
    93         stream << this->getSpeedAdd();
    94         std::string type2 = "speedAdd";
    95         std::string val2 = stream.str();
    96         this->pickupIdentifier_->addParameter(type2, val2);
    97 
    98         stream.clear();
    99         stream << this->getSpeedMultiply();
    100         std::string type3 = "speedMultiply";
    101         std::string val3 = stream.str();
    102         this->pickupIdentifier_->addParameter(type3, val3);
    103     }
    104 
    105     /**
    106     @brief
    10781        Method for creating a SpeedPickup object through XML.
    10882    */
     
    11488        XMLPortParam(SpeedPickup, "speedAdd", setSpeedAdd, getSpeedAdd, xmlelement, mode);
    11589        XMLPortParam(SpeedPickup, "speedMultiply", setSpeedMultiply, getSpeedMultiply, xmlelement, mode);
    116 
    117         this->initializeIdentifier();
    11890    }
    11991
     
    176148    {
    177149        PickupCarrier* carrier = this->getCarrier();
    178         SpaceShip* ship = dynamic_cast<SpaceShip*>(carrier);
     150        SpaceShip* ship = orxonox_cast<SpaceShip*>(carrier);
    179151
    180152        if(ship == NULL)
     
    184156
    185157        return ship;
    186     }
    187 
    188     /**
    189     @brief
    190         Creates a duplicate of the input OrxonoxClass.
    191     @param item
    192         A pointer to the Orxonox class.
    193     */
    194     void SpeedPickup::clone(OrxonoxClass*& item)
    195     {
    196         if(item == NULL)
    197             item = new SpeedPickup(this);
    198 
    199         SUPER(SpeedPickup, clone, item);
    200 
    201         SpeedPickup* pickup = dynamic_cast<SpeedPickup*>(item);
    202         pickup->setDuration(this->getDuration());
    203         pickup->setSpeedAdd(this->getSpeedAdd());
    204         pickup->setSpeedMultiply(this->getSpeedMultiply());
    205 
    206         pickup->initializeIdentifier();
    207158    }
    208159
  • code/trunk/src/modules/pickup/items/SpeedPickup.h

    r8727 r9348  
    8181
    8282            virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
    83             virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    8483
    8584            /**
     
    103102
    104103        protected:
    105             void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    106104            void pickupTimerCallback(void); //!< Function that gets called when timer ends.
    107105
     
    112110        private:
    113111            void initialize(void); //!< Initializes the member variables.
    114             SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceSHip, and throw an error message if the conversion fails.
     112            SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails.
    115113
    116114            Timer durationTimer_; //!< Timer.
Note: See TracChangeset for help on using the changeset viewer.