Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 18, 2009, 6:41:00 PM (16 years ago)
Author:
landauf
Message:

removed some debug output, cleanup in WeaponMode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.cc

    r2918 r2919  
    6363        this->damage_ = 0;
    6464        this->muzzleOffset_ = Vector3::ZERO;
    65 
    66 COUT(0) << "+WeaponMode" << std::endl;
    6765    }
    6866
    6967    WeaponMode::~WeaponMode()
    7068    {
    71 COUT(0) << "~WeaponMode" << std::endl;
    7269    }
    7370
     
    221218            return WorldEntity::FRONT;
    222219    }
    223 
    224 /*
    225     WeaponMode::WeaponMode(BaseObject* creator) : StaticEntity(creator)
    226     {
    227         RegisterObject(WeaponMode);
    228 
    229         this->bulletReadyToShoot_ = true;
    230         this->magazineReadyToShoot_ = true;
    231         this->weaponSystem_ = 0;
    232         this->weaponPack_ = 0;
    233         this->weaponSlot_ = 0;
    234         this->bulletLoadingTime_ = 0;
    235         this->magazineLoadingTime_ = 0;
    236         this->bReloading_ = false;
    237         this->bulletAmount_= 0;
    238         this->magazineAmount_ = 0;
    239         this->munition_ = 0;
    240         this->unlimitedMunition_ = false;
    241         this->setObjectMode(0x0);
    242 COUT(0) << "+WeaponMode" << std::endl;
    243     }
    244 
    245     WeaponMode::~WeaponMode()
    246     {
    247 COUT(0) << "~WeaponMode" << std::endl;
    248         if (this->isInitialized() && this->weaponPack_)
    249             this->weaponPack_->removeWeapon(this);
    250     }
    251 
    252     void WeaponMode::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    253     {
    254         SUPER(WeaponMode, XMLPort, xmlelement, mode);
    255 
    256         XMLPortParam(WeaponMode, "munitionType", setMunitionType, getMunitionType, xmlelement, mode);
    257         XMLPortParam(WeaponMode, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);
    258         XMLPortParam(WeaponMode, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode);
    259         XMLPortParam(WeaponMode, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);
    260         XMLPortParam(WeaponMode, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);
    261         XMLPortParam(WeaponMode, "unlimitedMunition", setUnlimitedMunition, getUnlimitedMunition, xmlelement, mode);
    262     }
    263 
    264     void WeaponMode::setWeapon()
    265     {
    266         this->munition_->fillBullets();
    267         this->munition_->fillMagazines();
    268     }
    269 
    270     void WeaponMode::setMunition()
    271     {
    272         this->munition_->setMaxBullets(this->bulletAmount_);
    273         this->munition_->setMaxMagazines(this->magazineAmount_);
    274     }
    275 
    276     void WeaponMode::fire()
    277     {
    278         if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)
    279         {
    280             this->bulletReadyToShoot_ = false;
    281             if ( this->unlimitedMunition_== true )
    282             {
    283                 //shoot
    284                 this->reloadBullet();
    285                 this->createProjectile();
    286             }
    287             else
    288             {
    289                 if ( this->munition_->bullets() > 0)
    290                 {
    291                     //shoot and reload
    292                     this->takeBullets();
    293                     this->reloadBullet();
    294                     this->createProjectile();
    295                 }
    296                 //if there are no bullets, but magazines
    297                 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
    298                 {
    299                     //reload magazine
    300                     this->takeMagazines();
    301                     this->reloadMagazine();
    302                 }
    303                 else
    304                 {
    305                     //no magazines
    306                 }
    307             }
    308         }
    309         else
    310         {
    311             //weapon not reloaded
    312         }
    313     }
    314 
    315 
    316     //weapon reloading
    317     void WeaponMode::bulletTimer(float bulletLoadingTime)
    318     {
    319         this->bReloading_ = true;
    320         this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&WeaponMode::bulletReloaded)));
    321     }
    322     void WeaponMode::magazineTimer(float magazineLoadingTime)
    323     {
    324         this->bReloading_ = true;
    325         this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&WeaponMode::magazineReloaded)));
    326     }
    327 
    328     void WeaponMode::bulletReloaded()
    329     {
    330         this->bReloading_ = false;
    331         this->bulletReadyToShoot_ = true;
    332     }
    333 
    334     void WeaponMode::magazineReloaded()
    335     {
    336         this->bReloading_ = false;
    337         this->munition_->fillBullets();
    338     }
    339 
    340 
    341 
    342     void WeaponMode::attachNeededMunition(const std::string& munitionName)
    343     {
    344         //  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
    345         if (this->weaponSystem_)
    346         {
    347             //getMunitionType returns 0 if there is no such munitionType
    348             Munition* munition = this->weaponSystem_->getMunitionType(munitionName);
    349             if ( munition )
    350             {
    351                 this->munition_ = munition;
    352                 this->setMunition();
    353             }
    354             else
    355             {
    356                 //create new munition with identifier because there is no such munitionType
    357                 this->munitionIdentifier_ = ClassByString(munitionName);
    358                 this->munition_ = this->munitionIdentifier_.fabricate(this);
    359                 this->weaponSystem_->setNewMunition(munitionName, this->munition_);
    360                 this->setMunition();
    361             }
    362         }
    363     }
    364 
    365 
    366     Munition * WeaponMode::getAttachedMunition(const std::string& munitionType)
    367     {
    368         this->munition_ = this->weaponSystem_->getMunitionType(munitionType);
    369         return this->munition_;
    370     }
    371 */
    372220}
Note: See TracChangeset for help on using the changeset viewer.