- Timestamp:
- Apr 18, 2009, 6:14:52 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapons/src/orxonox/objects/weaponSystem/Munition.h
r2912 r2918 20 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 21 * 22 * Author :22 * Authors: 23 23 * Martin Polak 24 * Fabian 'x3n' Landau 24 25 * Co-authors: 25 26 * ... … … 31 32 32 33 #include "OrxonoxPrereqs.h" 34 35 #include <map> 36 33 37 #include "core/BaseObject.h" 38 #include "tools/Timer.h" 34 39 35 40 namespace orxonox … … 37 42 class _OrxonoxExport Munition : public BaseObject 38 43 { 44 struct Magazine 45 { 46 public: 47 Magazine(Munition* munition, bool bUseReloadTime = true); 48 49 unsigned int munition_; 50 Timer<Magazine> loadTimer_; 51 bool bLoaded_; 52 53 private: 54 void loaded(Munition* munition); 55 }; 56 39 57 public: 40 58 Munition(BaseObject* creator); 41 59 virtual ~Munition(); 42 60 43 void setMaxBullets(unsigned int amount); 44 void setMaxMagazines(unsigned int amount); 61 unsigned int getNumMunition(WeaponMode* user) const; 62 unsigned int getNumMunitionInCurrentMagazine(WeaponMode* user) const; 63 unsigned int getNumMagazines() const; 45 64 46 void fillBullets(); 47 void fillMagazines(); 65 unsigned int getMaxMunition() const; 66 inline unsigned int getMaxMagazines() const 67 { return this->maxMagazines_; } 68 inline unsigned int getMaxMunitionPerMagazine() const 69 { return this->maxMunitionPerMagazine_; } 48 70 49 unsigned int bullets();50 unsigned int magazines();71 bool canTakeMunition(unsigned int amount, WeaponMode* user) const; 72 bool takeMunition(unsigned int amount, WeaponMode* user); 51 73 52 void removeBullets(unsigned int k); 53 void removeMagazines(unsigned int k); 54 void addBullets(unsigned int k); 55 void addMagazines(unsigned int k); 74 bool canReload() const; 75 bool needReload(WeaponMode* user) const; 76 bool reload(WeaponMode* user, bool bUseReloadTime = true); 77 inline float getReloadTime() const 78 { return this->reloadTime_; } 79 80 bool canAddMunition(unsigned int amount) const; 81 bool addMunition(unsigned int amount); 82 83 bool canAddMagazines(unsigned int amount) const; 84 bool addMagazines(unsigned int amount); 85 86 bool canRemoveMagazines(unsigned int amount) const; 87 bool removeMagazines(unsigned int amount); 88 89 bool dropMagazine(WeaponMode* user); 90 91 protected: 92 unsigned int maxMunitionPerMagazine_; 93 unsigned int maxMagazines_; 94 unsigned int magazines_; 95 std::map<WeaponMode*, Magazine*> currentMagazines_; 96 97 bool bUseSeparateMagazines_; 98 bool bStackMunition_; 99 bool bAllowMunitionRefilling_; 100 bool bAllowMultiMunitionRemovementUnderflow_; 101 102 float reloadTime_; 56 103 57 104 private: 58 59 protected: 60 unsigned int bullets_; 61 unsigned int magazines_; 62 unsigned int maxBullets_; 63 unsigned int maxMagazines_; 105 Magazine* getMagazine(WeaponMode* user) const; 64 106 }; 65 107 }
Note: See TracChangeset
for help on using the changeset viewer.