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

Location:
code/branches/weapons/src/orxonox/objects/weaponSystem
Files:
10 edited

Legend:

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

    r2915 r2919  
    4545        this->firemode_ = WeaponSystem::FIRE_MODE_UNASSIGNED;
    4646        this->weaponmode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED;
    47 
    48 COUT(0) << "+DefaultWeaponmodeLink" << std::endl;
    4947    }
    5048
    5149    DefaultWeaponmodeLink::~DefaultWeaponmodeLink()
    5250    {
    53 COUT(0) << "~DefaultWeaponmodeLink" << std::endl;
    5451    }
    5552
  • code/branches/weapons/src/orxonox/objects/weaponSystem/Munition.cc

    r2918 r2919  
    5151
    5252        this->reloadTime_ = 0;
    53 
    54 COUT(0) << "+Munition" << std::endl;
    5553    }
    5654
     
    5957        for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it)
    6058            delete it->second;
    61 
    62 COUT(0) << "~Munition" << std::endl;
    6359    }
    6460
  • code/branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc

    r2918 r2919  
    5353        this->reloadTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&Weapon::reloaded)));
    5454        this->reloadTimer_.stopTimer();
    55 
    56 COUT(0) << "+Weapon" << std::endl;
    5755    }
    5856
    5957    Weapon::~Weapon()
    6058    {
    61 COUT(0) << "~Weapon" << std::endl;
    62 
    6359        if (this->isInitialized())
    6460        {
  • 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}
  • code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.h

    r2918 r2919  
    151151            Timer<WeaponMode> reloadTimer_;
    152152            bool bReloading_;
    153 /*
    154             virtual void fire();
    155             void attachNeededMunition(const std::string& munitionType);
    156             Munition * getAttachedMunition(const std::string& munitiontype);
    157 
    158             //reloading
    159             void bulletTimer(float bulletLoadingTime);
    160             void magazineTimer(float magazineLoadingTime);
    161             void bulletReloaded();
    162             void magazineReloaded();
    163 
    164             //get and set functions for XMLPort
    165             void setMunitionType(const std::string& munitionType)
    166                 {   this->munitionType_ = munitionType; }
    167             std::string& getMunitionType() const
    168                 {   return this->munitionType_;  }
    169 
    170             void setBulletLoadingTime(float loadingTime)
    171                 {   this->bulletLoadingTime_ = loadingTime; }
    172             float getBulletLoadingTime() const
    173                 {   return this->bulletLoadingTime_;  }
    174 
    175             void setMagazineLoadingTime(float loadingTime)
    176                 {   this->magazineLoadingTime_ = loadingTime; }
    177             float getMagazineLoadingTime() const
    178                 {   return this->magazineLoadingTime_;  }
    179 
    180             void setBulletAmount(unsigned int amount)
    181                 {   this->bulletAmount_ = amount; }
    182             unsigned int getBulletAmount() const
    183                 {   return this->bulletAmount_;  }
    184 
    185             void setMagazineAmount(unsigned int amount)
    186                 {   this->magazineAmount_ = amount; }
    187             unsigned int getMagazineAmount() const
    188                 {   return this->magazineAmount_;   }
    189 
    190             void setUnlimitedMunition(bool unlimitedMunition)
    191                 {   this->unlimitedMunition_ = unlimitedMunition;   }
    192             bool getUnlimitedMunition() const
    193                 {   return this->unlimitedMunition_;    }
    194 
    195             //weapon actions
    196             //these function are defined in the weapon classes
    197             virtual void takeBullets() {}
    198             virtual void takeMagazines() {}
    199             virtual void createProjectile() {}
    200             virtual void reloadBullet() {}
    201             virtual void reloadMagazine() {}
    202 
    203             //manually set or reset
    204             virtual void setWeapon();
    205             virtual void setMunition();
    206 
    207             inline void setWeaponSystem(WeaponSystem *weaponSystem)
    208                 { this->weaponSystem_ = weaponSystem; };
    209             inline WeaponSystem * getWeaponSystem() const
    210                 { return this->weaponSystem_; };
    211 
    212             inline void setWeaponPack(WeaponPack *weaponPack)
    213                 { this->weaponPack_ = weaponPack; };
    214             inline WeaponPack * getWeaponPack() const
    215                 { return this->weaponPack_; };
    216 
    217             inline void setWeaponSlot(WeaponSlot * wSlot)
    218                 { this->weaponSlot_ = wSlot; }
    219             inline WeaponSlot * getWeaponSlot() const
    220                 { return this->weaponSlot_; }
    221 
    222         protected:
    223             bool bReloading_;
    224             bool bulletReadyToShoot_;
    225             bool magazineReadyToShoot_;
    226             bool unlimitedMunition_;
    227             float bulletLoadingTime_;
    228             float magazineLoadingTime_;
    229             unsigned int bulletAmount_;
    230             unsigned int magazineAmount_;
    231             std::string munitionType_;
    232 
    233             WeaponSlot * weaponSlot_;
    234             Munition * munition_;
    235             WeaponSystem * weaponSystem_;
    236             WeaponPack* weaponPack_;
    237 
    238             SubclassIdentifier<Munition> munitionIdentifier_;
    239 
    240             Timer<WeaponMode> bulletReloadTimer_;
    241             Timer<WeaponMode> magazineReloadTimer_;
    242 */
    243153    };
    244154}
  • code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.cc

    r2918 r2919  
    4848
    4949        this->weaponSystem_ = 0;
    50 
    51 COUT(0) << "+WeaponPack" << std::endl;
    5250    }
    5351
    5452    WeaponPack::~WeaponPack()
    5553    {
    56 COUT(0) << "~WeaponPack" << std::endl;
    57 
    5854        if (this->isInitialized() && this->weaponSystem_)
    5955        {
  • code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2918 r2919  
    4646        this->weaponSystem_ = 0;
    4747        this->desiredFiremode_ = WeaponSystem::FIRE_MODE_UNASSIGNED;
    48 
    49 COUT(0) << "+WeaponSet" << std::endl;
    5048    }
    5149
    5250    WeaponSet::~WeaponSet()
    5351    {
    54 COUT(0) << "~WeaponSet" << std::endl;
    55 
    5652        if (this->isInitialized() && this->weaponSystem_)
    5753            this->weaponSystem_->removeWeaponSet(this);
  • code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc

    r2918 r2919  
    4848
    4949        this->setObjectMode(0x0);
    50 
    51 COUT(0) << "+WeaponSlot" << std::endl;
    5250    }
    5351
    5452    WeaponSlot::~WeaponSlot()
    5553    {
    56 COUT(0) << "~WeaponSlot" << std::endl;
    57 
    5854        if (this->isInitialized() && this->weaponSystem_)
    5955            this->weaponSystem_->removeWeaponSlot(this);
  • code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    r2918 r2919  
    5353
    5454        this->pawn_ = 0;
    55 COUT(0) << "+WeaponSystem" << std::endl;
    5655    }
    5756
    5857    WeaponSystem::~WeaponSystem()
    5958    {
    60 COUT(0) << "~WeaponSystem" << std::endl;
    6159        if (this->isInitialized())
    6260        {
  • code/branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.cc

    r2918 r2919  
    6060        projectile->setPosition(this->getMuzzlePosition());
    6161        projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
     62        projectile->scale(5);
    6263
    6364        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
Note: See TracChangeset for help on using the changeset viewer.