Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 18, 2009, 6:14:52 PM (15 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/WeaponPack.cc

    r2915 r2918  
    7272        SUPER(WeaponPack, XMLPort, xmlelement, mode);
    7373
    74         XMLPortObject(WeaponPack, Weapon, "", addWeapon, getWeapon, xmlelement, mode);
     74        XMLPortObjectExtended(WeaponPack, Weapon, "", addWeapon, getWeapon, xmlelement, mode, false, false);
    7575        XMLPortObject(WeaponPack, DefaultWeaponmodeLink, "links", addDefaultWeaponmodeLink, getDefaultWeaponmodeLink, xmlelement, mode);
    7676    }
     
    7979    {
    8080        for (std::set<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    81             (*it)->fire();
     81            (*it)->fire(weaponmode);
     82    }
     83
     84    void WeaponPack::reload()
     85    {
     86        for (std::set<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
     87            (*it)->reload();
    8288    }
    8389
     
    114120    }
    115121
    116     void WeaponPack::setWeaponSystemToAllWeapons()
    117     {
    118         for (std::set<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    119             (*it)->setWeaponSystem(this->weaponSystem_);
    120     }
    121 
    122     void WeaponPack::attachNeededMunitionToAllWeapons()
    123     {
    124         for (std::set<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    125         {
    126             (*it)->attachNeededMunition((*it)->getMunitionType());
    127             (*it)->setWeapon();
    128         }
    129     }
    130 
    131122    void WeaponPack::addDefaultWeaponmodeLink(DefaultWeaponmodeLink* link)
    132123    {
     
    155146        return WeaponSystem::WEAPON_MODE_UNASSIGNED;
    156147    }
     148
     149    void WeaponPack::notifyWeapons()
     150    {
     151        for (std::set<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
     152            (*it)->setWeaponPack(this);
     153    }
    157154}
Note: See TracChangeset for help on using the changeset viewer.