[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 | |
---|
[2912] | 35 | #include <set> |
---|
| 36 | #include <map> |
---|
| 37 | |
---|
[2106] | 38 | #include "core/BaseObject.h" |
---|
| 39 | |
---|
| 40 | namespace orxonox |
---|
| 41 | { |
---|
| 42 | class _OrxonoxExport WeaponSystem : public BaseObject |
---|
| 43 | { |
---|
| 44 | public: |
---|
| 45 | WeaponSystem(BaseObject* creator); |
---|
| 46 | virtual ~WeaponSystem(); |
---|
| 47 | |
---|
[2914] | 48 | // adding and removing WeaponSlots |
---|
| 49 | void addWeaponSlot(WeaponSlot * wSlot); |
---|
| 50 | void removeWeaponSlot(WeaponSlot * wSlot); |
---|
[2912] | 51 | WeaponSlot * getWeaponSlot(unsigned int index) const; |
---|
[2106] | 52 | |
---|
[2914] | 53 | // adding and removing WeaponSets |
---|
| 54 | bool addWeaponSet(WeaponSet * wSet); |
---|
| 55 | bool addWeaponSet(WeaponSet * wSet, unsigned int firemode); |
---|
| 56 | void removeWeaponSet(WeaponSet * wSet); |
---|
[2912] | 57 | WeaponSet * getWeaponSet(unsigned int index) const; |
---|
[2106] | 58 | |
---|
[2914] | 59 | // adding and removing WeaponPacks |
---|
| 60 | bool canAddWeaponPack(WeaponPack * wPack); |
---|
| 61 | bool addWeaponPack(WeaponPack * wPack); |
---|
| 62 | void removeWeaponPack(WeaponPack * wPack); |
---|
[2912] | 63 | WeaponPack * getWeaponPack(unsigned int index) const; |
---|
[2106] | 64 | |
---|
[2914] | 65 | // configure slots and firemodes |
---|
| 66 | bool swapWeaponSlots(WeaponSlot * wSlot1, WeaponSlot * wSlot2); |
---|
| 67 | void changeWeaponmode(WeaponPack * wPack, WeaponSet * wSet, unsigned int weaponmode); |
---|
| 68 | |
---|
[2912] | 69 | void fire(unsigned int firemode); |
---|
| 70 | |
---|
[2914] | 71 | |
---|
[2912] | 72 | void setNewMunition(const std::string& munitionType, Munition * munitionToAdd); |
---|
| 73 | void setNewSharedMunition(const std::string& munitionType, Munition * munitionToAdd); |
---|
| 74 | Munition * getMunitionType(const std::string& munitionType) const; |
---|
| 75 | |
---|
| 76 | inline void setPawn(Pawn * pawn) |
---|
| 77 | { this->pawn_ = pawn; } |
---|
| 78 | inline Pawn * getPawn() const |
---|
| 79 | { return this->pawn_; } |
---|
| 80 | |
---|
| 81 | inline int getWeaponSlotSize() const |
---|
[2662] | 82 | { return this->weaponSlots_.size(); } |
---|
[2106] | 83 | |
---|
[2914] | 84 | static inline unsigned int getFiremodeMask(unsigned int firemode) |
---|
[2912] | 85 | { return (0x1 << firemode); } |
---|
| 86 | |
---|
[2914] | 87 | static const unsigned int MAX_FIRE_MODES = 8; |
---|
| 88 | static const unsigned int FIRE_MODE_UNASSIGNED = (unsigned int)-1; |
---|
| 89 | |
---|
| 90 | static const unsigned int MAX_WEAPON_MODES = 8; |
---|
| 91 | static const unsigned int WEAPON_MODE_UNASSIGNED = (unsigned int)-1; |
---|
| 92 | |
---|
[2106] | 93 | private: |
---|
[2912] | 94 | std::map<unsigned int, WeaponSet *> weaponSets_; |
---|
| 95 | std::set<WeaponSlot *> weaponSlots_; |
---|
| 96 | std::set<WeaponPack *> weaponPacks_; |
---|
[2662] | 97 | std::map<std::string, Munition *> munitionSet_; |
---|
[2912] | 98 | Pawn * pawn_; |
---|
[2106] | 99 | }; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | #endif /* _WeaponSystem_H__ */ |
---|