Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Added many new features in the Munition class:

  • there are now 3 modes: a) every weapon has it's own magazine b) all weapons use the same magazin c) no magazines, just a big munition pool
  • the Munition class handles the reloading of the magazine

Split the Weapon class into Weapon and WeaponMode. WeaponMode creates the fire of the Weapon. A weapon can own several WeaponModes (for example primary and secondary fire). But it's also possible to have a weapon with several muzzles which all fire at the same time (there's a WeaponMode for each muzzle).

Renamed LaserGun to LaserFire and Fusion to FusionFire. They inherit now from WeaponMode.

Changed the code in the Weapon class to use the new Munition functionality.

Added ReplenishingMunition, a subclass of Munition that replenishes itself (used for LaserGunMunition).

Added a reload command to reload magazines.

File:
1 edited

Legend:

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

    r2915 r2918  
    6464        XMLPortParam(WeaponSet, "firemode", setDesiredFiremode, getDesiredFiremode, xmlelement, mode);
    6565    }
    66 /*
    67     void WeaponSet::attachWeaponPack(WeaponPack *wPack)
    68     {
    69         if ( this->weaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->weaponSystem_->getWeaponSlotSize() ) )
    70         {
    71             this->attachedWeaponPack_ = wPack;
    72             int wPackWeapon = 0;    //WeaponCounter for Attaching
    73 
    74             //should be possible to choose which slot to use
    75             //attach every weapon of the weaponPack to a weaponSlot
    76             for (  int i=0; i < wPack->getSize() ; i++  )
    77             {
    78                 //at the moment this function only works for one weaponPack in the entire WeaponSystem...
    79                 //it also takes the first free weaponSlot...
    80                 if ( this->weaponSystem_->getWeaponSlot(i)->getAttachedWeapon() == 0 && this->weaponSystem_->getWeaponSlot(i) != 0) //if slot not full
    81                 {
    82                     this->setWeaponSlots_.push_back( this->weaponSystem_->getWeaponSlot(i) );
    83                     this->weaponSystem_->getWeaponSlot(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
    84                     this->weaponSystem_->getPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );
    85                     wPackWeapon++;
    86                 }
    87                 else
    88                 {
    89                     for (int k=0; k < this->weaponSystem_->getWeaponSlotSize(); k++)
    90                     {
    91                         if ( this->weaponSystem_->getWeaponSlot(k)->getAttachedWeapon() == 0 )
    92                         {
    93                             this->setWeaponSlots_.push_back( this->weaponSystem_->getWeaponSlot(k) );
    94                             this->weaponSystem_->getWeaponSlot(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
    95                             this->weaponSystem_->getPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );
    96                             wPackWeapon++;
    97                         }
    98                     }
    99                 }
    100             }
    101         }
    102     }
    103 */
    10466
    10567    void WeaponSet::fire()
     
    10971            if (it->second != WeaponSystem::WEAPON_MODE_UNASSIGNED)
    11072                it->first->fire(it->second);
     73    }
     74
     75    void WeaponSet::reload()
     76    {
     77        // fire all WeaponPacks with their defined weaponmode
     78        for (std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it)
     79            it->first->reload();
    11180    }
    11281
Note: See TracChangeset for help on using the changeset viewer.