Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 3, 2008, 5:13:34 PM (15 years ago)
Author:
polakma
Message:

fixed attaching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc

    r2327 r2331  
    5454    {
    5555        SUPER(Weapon, XMLPort, xmlelement, mode);
     56        XMLPortParam(Weapon, "munitionType", setMunitionType, getMunitionType, xmlelement, mode);
    5657    }
    5758
     
    8182    {
    8283        //if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
    83         if ( this->parentWeaponSystem_->getMunitionType(munitionName) )
    84             this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionName);
    85         else
     84        if (this->parentWeaponSystem_)
    8685        {
    87             //create new munition with identifier
    88             this->munitionIdentifier_ = ClassByString(munitionName);
    89             this->munition_ = this->munitionIdentifier_.fabricate(this);
    90             this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
     86            Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
     87            if ( munition )
     88                this->munition_ = munition;
     89            else
     90            {
     91                //create new munition with identifier
     92                this->munitionIdentifier_ = ClassByString(munitionName);
     93                this->munition_ = this->munitionIdentifier_.fabricate(this);
     94                this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
     95            }
    9196        }
    9297    }
     
    96101     *
    97102     */
     103
     104    void Weapon::setMunitionType(std::string munitionType)
     105    {   this->munitionType_ = munitionType; }
     106
     107    std::string Weapon::getMunitionType()
     108    {   return this->munitionType_;  }
     109
    98110    Munition * Weapon::getAttachedMunition()
    99111    {   return this->munition_; }
Note: See TracChangeset for help on using the changeset viewer.