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/Weapon.h

    r2914 r2918  
    2222 *   Author:
    2323 *      Martin Polak
     24 *      Fabian 'x3n' Landau
    2425 *   Co-authors:
    2526 *      ...
     
    3435
    3536#include "tools/Timer.h"
    36 #include "core/Identifier.h"
    3737
    3838namespace orxonox
     
    4646            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4747
    48             virtual void fire();
    49             void attachNeededMunition(const std::string& munitionType);
    50             Munition * getAttachedMunition(const std::string& munitiontype);
     48            void fire(unsigned int mode);
     49            void reload();
    5150
    52             //reloading
    53             void bulletTimer(float bulletLoadingTime);
    54             void magazineTimer(float magazineLoadingTime);
    55             void bulletReloaded();
    56             void magazineReloaded();
     51            void addWeaponmode(WeaponMode* weaponmode);
     52            WeaponMode* getWeaponmode(unsigned int index) const;
    5753
    58             //XMLPort functions
    59             virtual void setMunitionType(const std::string& munitionType);
    60             virtual const std::string& getMunitionType() const;
    61             virtual void setBulletLoadingTime(float loadingTime);
    62             virtual const float getBulletLoadingTime() const;
    63             virtual void setMagazineLoadingTime(float loadingTime);
    64             virtual const float getMagazineLoadingTime() const;
    65             virtual void setBulletAmount(unsigned int amount);
    66             virtual const unsigned int getBulletAmount() const;
    67             virtual void setMagazineAmount(unsigned int amount);
    68             virtual const unsigned int getMagazineAmount() const;
    69             virtual void setUnlimitedMunition(bool unlimitedMunition);
    70             virtual const bool getUnlimitedMunition() const;
    71 
    72             //weapon actions
    73             virtual void takeBullets();
    74             virtual void takeMagazines();
    75             virtual void createProjectile();
    76             virtual void reloadBullet();
    77             virtual void reloadMagazine();
    78 
    79             //manually set or reset
    80             virtual void setWeapon();
    81             virtual void setMunition();
    82 
    83             inline void setWeaponSystem(WeaponSystem *weaponSystem)
    84                 { this->weaponSystem_ = weaponSystem; };
    85             inline WeaponSystem * getWeaponSystem() const
    86                 { return this->weaponSystem_; };
    87 
    88             inline void setWeaponPack(WeaponPack *weaponPack)
    89                 { this->weaponPack_ = weaponPack; };
     54            inline void setWeaponPack(WeaponPack * weaponPack)
     55                { this->weaponPack_ = weaponPack; this->notifyWeaponModes(); }
    9056            inline WeaponPack * getWeaponPack() const
    91                 { return this->weaponPack_; };
     57                { return this->weaponPack_; }
    9258
    9359            inline void setWeaponSlot(WeaponSlot * wSlot)
     
    9662                { return this->weaponSlot_; }
    9763
    98         protected:
     64        private:
     65            void reloaded();
     66            void notifyWeaponModes();
     67
     68            WeaponPack* weaponPack_;
     69            WeaponSlot* weaponSlot_;
     70            std::multimap<unsigned int, WeaponMode*> weaponmodes_;
     71
     72            Timer<Weapon> reloadTimer_;
    9973            bool bReloading_;
    100             bool bulletReadyToShoot_;
    101             bool magazineReadyToShoot_;
    102             bool unlimitedMunition_;
    103             float bulletLoadingTime_;
    104             float magazineLoadingTime_;
    105             unsigned int bulletAmount_;
    106             unsigned int magazineAmount_;
    107             std::string munitionType_;
    108 
    109             WeaponSlot * weaponSlot_;
    110             Munition * munition_;
    111             WeaponSystem * weaponSystem_;
    112             WeaponPack* weaponPack_;
    113 
    114             SubclassIdentifier<Munition> munitionIdentifier_;
    115 
    116             Timer<Weapon> bulletReloadTimer_;
    117             Timer<Weapon> magazineReloadTimer_;
     74            unsigned int reloadingWeaponmode_;
    11875    };
    11976}
Note: See TracChangeset for help on using the changeset viewer.