[2106] | 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 | * |
---|
| 22 | * Author: |
---|
| 23 | * Martin Polak |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | #ifndef _WeaponSystem_H__ |
---|
| 31 | #define _WeaponSystem_H__ |
---|
| 32 | |
---|
| 33 | #include "OrxonoxPrereqs.h" |
---|
| 34 | |
---|
[3196] | 35 | #include <map> |
---|
[2912] | 36 | #include <set> |
---|
[2915] | 37 | #include <vector> |
---|
[2106] | 38 | #include "core/BaseObject.h" |
---|
| 39 | |
---|
| 40 | namespace orxonox |
---|
| 41 | { |
---|
[10650] | 42 | /** |
---|
| 43 | @brief |
---|
| 44 | An @ref orxonox::Pawn that is able to fire weapons always need to have a WeaponSystem. The WeaponSystem manages all the @ref orxonox::WeaponSet, @ref orxonox::WeaponPack and @ref orxonox::WeaponSlot classes. |
---|
| 45 | |
---|
| 46 | */ |
---|
[2106] | 47 | class _OrxonoxExport WeaponSystem : public BaseObject |
---|
| 48 | { |
---|
| 49 | public: |
---|
[9667] | 50 | WeaponSystem(Context* context); |
---|
[2106] | 51 | virtual ~WeaponSystem(); |
---|
| 52 | |
---|
[2914] | 53 | // adding and removing WeaponSlots |
---|
| 54 | void addWeaponSlot(WeaponSlot * wSlot); |
---|
| 55 | void removeWeaponSlot(WeaponSlot * wSlot); |
---|
[2912] | 56 | WeaponSlot * getWeaponSlot(unsigned int index) const; |
---|
[2106] | 57 | |
---|
[2914] | 58 | // adding and removing WeaponSets |
---|
| 59 | bool addWeaponSet(WeaponSet * wSet); |
---|
| 60 | bool addWeaponSet(WeaponSet * wSet, unsigned int firemode); |
---|
| 61 | void removeWeaponSet(WeaponSet * wSet); |
---|
[2912] | 62 | WeaponSet * getWeaponSet(unsigned int index) const; |
---|
[2106] | 63 | |
---|
[2914] | 64 | // adding and removing WeaponPacks |
---|
| 65 | bool canAddWeaponPack(WeaponPack * wPack); |
---|
| 66 | bool addWeaponPack(WeaponPack * wPack); |
---|
| 67 | void removeWeaponPack(WeaponPack * wPack); |
---|
[2912] | 68 | WeaponPack * getWeaponPack(unsigned int index) const; |
---|
[11071] | 69 | inline const std::vector<WeaponPack *>& getAllWeaponPacks() const |
---|
| 70 | { return weaponPacks_; } |
---|
[2106] | 71 | |
---|
[2914] | 72 | // configure slots and firemodes |
---|
| 73 | bool swapWeaponSlots(WeaponSlot * wSlot1, WeaponSlot * wSlot2); |
---|
| 74 | void changeWeaponmode(WeaponPack * wPack, WeaponSet * wSet, unsigned int weaponmode); |
---|
| 75 | |
---|
[2912] | 76 | void fire(unsigned int firemode); |
---|
[2918] | 77 | void reload(); |
---|
[2912] | 78 | |
---|
[2918] | 79 | Munition * getMunition(SubclassIdentifier<Munition> * identifier); |
---|
[11052] | 80 | void addMunition(Munition* munition); |
---|
[2914] | 81 | |
---|
[2912] | 82 | inline void setPawn(Pawn * pawn) |
---|
| 83 | { this->pawn_ = pawn; } |
---|
| 84 | inline Pawn * getPawn() const |
---|
| 85 | { return this->pawn_; } |
---|
| 86 | |
---|
| 87 | inline int getWeaponSlotSize() const |
---|
[2662] | 88 | { return this->weaponSlots_.size(); } |
---|
[2106] | 89 | |
---|
[2914] | 90 | static inline unsigned int getFiremodeMask(unsigned int firemode) |
---|
[2912] | 91 | { return (0x1 << firemode); } |
---|
| 92 | |
---|
[2914] | 93 | static const unsigned int MAX_FIRE_MODES = 8; |
---|
[3301] | 94 | static const unsigned int FIRE_MODE_UNASSIGNED = static_cast<unsigned int>(-1); |
---|
[2914] | 95 | |
---|
| 96 | static const unsigned int MAX_WEAPON_MODES = 8; |
---|
[3301] | 97 | static const unsigned int WEAPON_MODE_UNASSIGNED = static_cast<unsigned int>(-1); |
---|
[2914] | 98 | |
---|
[2106] | 99 | private: |
---|
[11052] | 100 | void updateMunition(); |
---|
| 101 | |
---|
[2912] | 102 | std::map<unsigned int, WeaponSet *> weaponSets_; |
---|
[2915] | 103 | std::vector<WeaponSlot *> weaponSlots_; |
---|
[6417] | 104 | std::vector<WeaponPack *> weaponPacks_; |
---|
[2918] | 105 | std::map<Identifier *, Munition *> munitions_; |
---|
[2912] | 106 | Pawn * pawn_; |
---|
[2106] | 107 | }; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | #endif /* _WeaponSystem_H__ */ |
---|