Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2337


Ignore:
Timestamp:
Dec 3, 2008, 6:26:53 PM (15 years ago)
Author:
polakma
Message:

fixed parentWeaponSystem-Pointer for all WeaponPacks and its Weapons

Location:
code/branches/weapon2/src/orxonox/objects
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Munition.h

    r2232 r2337  
    5959
    6060        private:
     61
     62        protected:
    6163            unsigned int bullets_;
    6264            unsigned int magazines_;
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc

    r2331 r2337  
    4444        this->bulletReadyToShoot_ = true;
    4545        this->magazineReadyToShoot_ = true;
     46        this->parentWeaponSystem_ = 0;
     47        this->parentWeaponSlot_ = 0;
     48        this->munition_ = 0;
    4649    }
    4750
     
    9093            {
    9194                //create new munition with identifier
     95COUT(0) << "Weapon::attachNeededMunition, create new Munition of Type " << munitionName << std::endl;
    9296                this->munitionIdentifier_ = ClassByString(munitionName);
    9397                this->munition_ = this->munitionIdentifier_.fabricate(this);
     
    108112    {   return this->munitionType_;  }
    109113
    110     Munition * Weapon::getAttachedMunition()
    111     {   return this->munition_; }
     114    Munition * Weapon::getAttachedMunition(std::string munitionType)
     115    {   
     116COUT(0) << "Weapon::getAttachedMunition, parentWeaponSystem_="<< this->parentWeaponSystem_ << std::endl;   
     117        this->parentWeaponSystem_->getMunitionType(munitionType);
     118COUT(0) << "Weapon::getAttachedMunition, munition_="<< this->munition_ << std::endl;
     119return this->munition_; }
    112120
    113121    void Weapon::setBulletLoadingTime(float loadingTime)
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.h

    r2331 r2337  
    5252            virtual void fire();
    5353            void attachNeededMunition(std::string munitionType);
    54             Munition * getAttachedMunition();
     54            Munition * getAttachedMunition(std::string munitiontype);
    5555
    5656            //reloading
     
    8383
    8484        private:
     85
     86        protected:
    8587            bool bulletReadyToShoot_;
    8688            bool magazineReadyToShoot_;
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponPack.cc

    r2331 r2337  
    104104        return weapons_[index];
    105105    }
     106
     107    void WeaponPack::setWeaponSystemToAllWeapons(WeaponSystem * weaponSystem)
     108    {
     109        for (int i=0; i < (int) this->weapons_.size(); i++)
     110        {
     111            this->weapons_[i]->setParentWeaponSystem(weaponSystem);
     112        }
     113       
     114    }
    106115}
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponPack.h

    r2319 r2337  
    6060            Weapon * getWeapon(unsigned int index);
    6161
     62            void setWeaponSystemToAllWeapons(WeaponSystem * weaponSystem);
     63
    6264            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
    6365                { parentWeaponSystem_=parentWeaponSystem; }
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2327 r2337  
    4646
    4747        this->parentWeaponSystem_ = 0;
    48 
     48        this->attachedWeaponPack_ = 0;
    4949    }
    5050
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    r2331 r2337  
    8484        this->munitionSet_[munitionType] = munitionToAdd;
    8585    }
     86
     87    //returns the Pointer to the munitionType
    8688    Munition * WeaponSystem::getMunitionType(std::string munitionType)
    8789    {
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc

    r2186 r2337  
    3737namespace orxonox
    3838{
     39    CreateFactory(LaserGunMunition);
     40
    3941    LaserGunMunition::LaserGunMunition(BaseObject* creator) : Munition(creator)
    4042    {
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc

    r2331 r2337  
    6161        if ( this->getBulletReadyToShoot() && this->getMagazineReadyToShoot() )
    6262        {
     63COUT(0) << "LaserGun::fire - ready to shoot" << std::endl;   
    6364            //take munition
    64             this->getAttachedMunition()->removeBullets(1,this);
     65            this->getAttachedMunition(this->munitionType_)->removeBullets(1,this);
    6566            Weapon::bulletTimer();
    6667            this->setBulletReadyToShoot(false);
  • code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2327 r2337  
    167167    {   
    168168COUT(0) << "Pawn::setWeaponPack" << std::endl;
    169         this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() );   }
     169        this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() );
     170        wPack->setParentWeaponSystem(this->weaponSystem_);
     171        wPack->setWeaponSystemToAllWeapons(this->weaponSystem_);
     172    }
     173
    170174    WeaponPack * Pawn::getWeaponPack(unsigned int firemode) const
    171175    {   return this->weaponSystem_->getWeaponPackPointer(firemode);    }
Note: See TracChangeset for help on using the changeset viewer.