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/Pickup.cc

    r8864 r9348  
    3737#include "util/StringUtils.h"
    3838
    39 #include "pickup/PickupIdentifier.h"
    40 
    41 #include "DroppedPickup.h"
     39#include "PickupSpawner.h"
    4240
    4341namespace orxonox
     
    8684    /**
    8785    @brief
    88         Initializes the PickupIdentififer of this Pickup.
    89     */
    90     void Pickup::initializeIdentifier(void)
    91     {
    92         std::string val1 = this->getActivationType();
    93         std::string type1 = "activationType";
    94         this->pickupIdentifier_->addParameter(type1, val1);
    95 
    96         std::string val2 = this->getDurationType();
    97         std::string type2 = "durationType";
    98         this->pickupIdentifier_->addParameter(type2, val2);
    99     }
    100 
    101     /**
    102     @brief
    10386        Method for creating a Pickup object through XML.
    10487    */
     
    10790        SUPER(Pickup, XMLPort, xmlelement, mode);
    10891
    109         XMLPortParam(Pickup, "activationType", setActivationType, getActivationType, xmlelement, mode);
    110         XMLPortParam(Pickup, "durationType", setDurationType, getDurationType, xmlelement, mode);
    111 
    112         this->initializeIdentifier();
     92        XMLPortParam(Pickup, "representation", setRepresentationName, getRepresentationName, xmlelement, mode);
     93        XMLPortParam(Pickup, "activationType", setActivationTypeAsString, getActivationTypeAsString, xmlelement, mode);
     94        XMLPortParam(Pickup, "durationType", setDurationTypeAsString, getDurationTypeAsString, xmlelement, mode);
    11395    }
    11496
     
    119101        Returns a string containing the activation type.
    120102    */
    121     const std::string& Pickup::getActivationType(void) const
     103    const std::string& Pickup::getActivationTypeAsString(void) const
    122104    {
    123         switch(this->activationType_)
     105        switch(this->getActivationType())
    124106        {
    125107            case pickupActivationType::immediate:
     
    138120        Returns a string containing the duration type.
    139121    */
    140     const std::string& Pickup::getDurationType(void) const
     122    const std::string& Pickup::getDurationTypeAsString(void) const
    141123    {
    142         switch(this->durationType_)
     124        switch(this->getDurationType())
    143125        {
    144126            case pickupDurationType::once:
     
    157139        The activation type of the Pickup as a string.
    158140    */
    159     void Pickup::setActivationType(const std::string& type)
     141    void Pickup::setActivationTypeAsString(const std::string& type)
    160142    {
    161143        if(type == Pickup::activationTypeImmediate_s)
    162             this->activationType_ = pickupActivationType::immediate;
     144            this->setActivationType(pickupActivationType::immediate);
    163145        else if(type == Pickup::activationTypeOnUse_s)
    164             this->activationType_ = pickupActivationType::onUse;
     146            this->setActivationType(pickupActivationType::onUse);
    165147        else
    166148            orxout(internal_error, context::pickups) << "Invalid activationType '" << type << "' in " << this->getIdentifier()->getName() << "." << endl;
     
    173155        The duration type of the Pickup as a string.
    174156    */
    175     void Pickup::setDurationType(const std::string& type)
     157    void Pickup::setDurationTypeAsString(const std::string& type)
    176158    {
    177159        if(type == Pickup::durationTypeOnce_s)
    178             this->durationType_ = pickupDurationType::once;
     160            this->setDurationType(pickupDurationType::once);
    179161        else if(type == Pickup::durationTypeContinuous_s)
    180             this->durationType_ = pickupDurationType::continuous;
     162            this->setDurationType(pickupDurationType::continuous);
    181163        else
    182164            orxout(internal_error, context::pickups) << "Invalid durationType '" << type << "' in " << this->getIdentifier()->getName() << "." << endl;
     
    199181    /**
    200182    @brief
    201         Creates a duplicate of the OrxonoxClass.
    202     @param item
    203         A reference to the pointer of the item that we're duplicating.
    204     */
    205     void Pickup::clone(OrxonoxClass*& item)
    206     {
    207         if(item == NULL)
    208             item = new Pickup(this);
    209 
    210         SUPER(Pickup, clone, item);
    211 
    212         Pickup* pickup = dynamic_cast<Pickup*>(item);
    213         pickup->setActivationTypeDirect(this->getActivationTypeDirect());
    214         pickup->setDurationTypeDirect(this->getDurationTypeDirect());
    215 
    216         pickup->initializeIdentifier();
    217     }
    218 
    219     /**
    220     @brief
    221183        Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    222         This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
    223         DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position);
    224184    @return
    225185        Returns true if a spawner was created, false if not.
     
    227187    bool Pickup::createSpawner(void)
    228188    {
    229         new DroppedPickup(this, this, this->getCarrier());
     189        PickupSpawner::createDroppedPickup(this, this, this->getCarrier());
    230190        return true;
    231191    }
Note: See TracChangeset for help on using the changeset viewer.