| [2049] | 1 | /* | 
|---|
 | 2 |  *   ORXONOX - the hottest 3D action shooter ever to exist | 
|---|
 | 3 |  *                    > www.orxonox.net < | 
|---|
 | 4 |  * | 
|---|
 | 5 |  * | 
|---|
 | 6 |  *   License notice: | 
|---|
 | 7 |  * | 
|---|
 | 8 |  *   This program is free software; you can redistribute it and/or | 
|---|
 | 9 |  *   modify it under the terms of the GNU General Public License | 
|---|
 | 10 |  *   as published by the Free Software Foundation; either version 2 | 
|---|
 | 11 |  *   of the License, or (at your option) any later version. | 
|---|
 | 12 |  * | 
|---|
 | 13 |  *   This program is distributed in the hope that it will be useful, | 
|---|
 | 14 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
 | 15 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
 | 16 |  *   GNU General Public License for more details. | 
|---|
 | 17 |  * | 
|---|
 | 18 |  *   You should have received a copy of the GNU General Public License | 
|---|
 | 19 |  *   along with this program; if not, write to the Free Software | 
|---|
 | 20 |  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. | 
|---|
 | 21 |  * | 
|---|
| [2918] | 22 |  *   Authors: | 
|---|
| [2049] | 23 |  *      Martin Polak | 
|---|
| [2918] | 24 |  *      Fabian 'x3n' Landau | 
|---|
| [2049] | 25 |  *   Co-authors: | 
|---|
 | 26 |  *      ... | 
|---|
 | 27 |  * | 
|---|
 | 28 |  */ | 
|---|
 | 29 |  | 
|---|
 | 30 | #ifndef _Munition_H__ | 
|---|
 | 31 | #define _Munition_H__ | 
|---|
 | 32 |  | 
|---|
 | 33 | #include "OrxonoxPrereqs.h" | 
|---|
| [2918] | 34 |  | 
|---|
 | 35 | #include <map> | 
|---|
| [2049] | 36 | #include "core/BaseObject.h" | 
|---|
| [2918] | 37 | #include "tools/Timer.h" | 
|---|
| [2049] | 38 |  | 
|---|
 | 39 | namespace orxonox | 
|---|
 | 40 | { | 
|---|
 | 41 |     class _OrxonoxExport Munition : public BaseObject | 
|---|
 | 42 |     { | 
|---|
| [2918] | 43 |         struct Magazine | 
|---|
 | 44 |         { | 
|---|
 | 45 |             public: | 
|---|
 | 46 |                 Magazine(Munition* munition, bool bUseReloadTime = true); | 
|---|
| [7851] | 47 |                 virtual ~Magazine() {} | 
|---|
| [2918] | 48 |  | 
|---|
 | 49 |                 unsigned int munition_; | 
|---|
| [5929] | 50 |                 Timer loadTimer_; | 
|---|
| [2918] | 51 |                 bool bLoaded_; | 
|---|
 | 52 |  | 
|---|
 | 53 |             private: | 
|---|
 | 54 |                 void loaded(Munition* munition); | 
|---|
 | 55 |         }; | 
|---|
 | 56 |  | 
|---|
| [2049] | 57 |         public: | 
|---|
| [9667] | 58 |             Munition(Context* context); | 
|---|
| [2049] | 59 |             virtual ~Munition(); | 
|---|
 | 60 |  | 
|---|
| [2918] | 61 |             unsigned int getNumMunition(WeaponMode* user) const; | 
|---|
 | 62 |             unsigned int getNumMunitionInCurrentMagazine(WeaponMode* user) const; | 
|---|
 | 63 |             unsigned int getNumMagazines() const; | 
|---|
| [2049] | 64 |  | 
|---|
| [2918] | 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_; } | 
|---|
| [2662] | 70 |  | 
|---|
| [2918] | 71 |             bool canTakeMunition(unsigned int amount, WeaponMode* user) const; | 
|---|
 | 72 |             bool takeMunition(unsigned int amount, WeaponMode* user); | 
|---|
| [2662] | 73 |  | 
|---|
| [2918] | 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_; } | 
|---|
| [2662] | 79 |  | 
|---|
| [2918] | 80 |             bool canAddMunition(unsigned int amount) const; | 
|---|
 | 81 |             bool addMunition(unsigned int amount); | 
|---|
| [2049] | 82 |  | 
|---|
| [2918] | 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 |  | 
|---|
| [2662] | 91 |         protected: | 
|---|
| [2918] | 92 |             unsigned int maxMunitionPerMagazine_; | 
|---|
 | 93 |             unsigned int maxMagazines_; | 
|---|
| [2662] | 94 |             unsigned int magazines_; | 
|---|
| [2918] | 95 |             std::map<WeaponMode*, Magazine*> currentMagazines_; | 
|---|
 | 96 |  | 
|---|
 | 97 |             bool bUseSeparateMagazines_; | 
|---|
 | 98 |             bool bStackMunition_; | 
|---|
 | 99 |             bool bAllowMunitionRefilling_; | 
|---|
 | 100 |             bool bAllowMultiMunitionRemovementUnderflow_; | 
|---|
 | 101 |  | 
|---|
 | 102 |             float reloadTime_; | 
|---|
 | 103 |  | 
|---|
 | 104 |         private: | 
|---|
 | 105 |             Magazine* getMagazine(WeaponMode* user) const; | 
|---|
| [2049] | 106 |     }; | 
|---|
 | 107 | } | 
|---|
 | 108 |  | 
|---|
| [2106] | 109 | #endif /* _Munition_H__ */ | 
|---|