| [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 | * |
|---|
| 22 | * Author: |
|---|
| 23 | * Martin Polak |
|---|
| [2918] | 24 | * Fabian 'x3n' Landau |
|---|
| [2049] | 25 | * Co-authors: |
|---|
| 26 | * ... |
|---|
| 27 | * |
|---|
| 28 | */ |
|---|
| 29 | |
|---|
| 30 | #ifndef _Weapon_H__ |
|---|
| 31 | #define _Weapon_H__ |
|---|
| 32 | |
|---|
| 33 | #include "OrxonoxPrereqs.h" |
|---|
| 34 | |
|---|
| [3196] | 35 | #include <map> |
|---|
| [2662] | 36 | #include "tools/Timer.h" |
|---|
| [5735] | 37 | #include "worldentities/StaticEntity.h" |
|---|
| [2049] | 38 | |
|---|
| 39 | namespace orxonox |
|---|
| 40 | { |
|---|
| [10650] | 41 | /** |
|---|
| 42 | @brief |
|---|
| 43 | A Weapon is a StaticEntity that can be attached to a WeaponSlot. A Weapon can shoot with different @ref orxonox::WeaponMode modes. |
|---|
| 44 | Imagine for example that a machine gun can shoot normal bullets, tracer bullets or even grenades. |
|---|
| 45 | */ |
|---|
| [2662] | 46 | class _OrxonoxExport Weapon : public StaticEntity |
|---|
| [2049] | 47 | { |
|---|
| 48 | public: |
|---|
| [9667] | 49 | Weapon(Context* context); |
|---|
| [2049] | 50 | virtual ~Weapon(); |
|---|
| 51 | |
|---|
| [11071] | 52 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; |
|---|
| [2096] | 53 | |
|---|
| [11174] | 54 | void push(unsigned int mode); |
|---|
| [11164] | 55 | void release(unsigned int mode); |
|---|
| [2918] | 56 | void reload(); |
|---|
| [2049] | 57 | |
|---|
| [2918] | 58 | void addWeaponmode(WeaponMode* weaponmode); |
|---|
| 59 | WeaponMode* getWeaponmode(unsigned int index) const; |
|---|
| [11071] | 60 | inline const std::multimap<unsigned int, WeaponMode*>& getAllWeaponmodes() const |
|---|
| 61 | { return weaponmodes_; } |
|---|
| [11052] | 62 | inline int getNumWeaponModes() const |
|---|
| 63 | { return weaponmodes_.size(); } |
|---|
| [2662] | 64 | |
|---|
| [10650] | 65 | /** |
|---|
| 66 | @brief |
|---|
| 67 | This function is called by a @ref orxonox::WeaponPack if this Weapon is added to the WeaponPack. |
|---|
| 68 | */ |
|---|
| [2918] | 69 | inline void setWeaponPack(WeaponPack * weaponPack) |
|---|
| 70 | { this->weaponPack_ = weaponPack; this->notifyWeaponModes(); } |
|---|
| [2914] | 71 | inline WeaponPack * getWeaponPack() const |
|---|
| [2918] | 72 | { return this->weaponPack_; } |
|---|
| [2662] | 73 | |
|---|
| [10650] | 74 | /** |
|---|
| 75 | @brief |
|---|
| 76 | This function is called by a @ref orxonox::WeaponSlot if this Weapon gets attached to the WeaponSlot. |
|---|
| 77 | */ |
|---|
| [2914] | 78 | inline void setWeaponSlot(WeaponSlot * wSlot) |
|---|
| 79 | { this->weaponSlot_ = wSlot; } |
|---|
| 80 | inline WeaponSlot * getWeaponSlot() const |
|---|
| 81 | { return this->weaponSlot_; } |
|---|
| [11052] | 82 | void updateMunition(); |
|---|
| [2914] | 83 | |
|---|
| [2918] | 84 | private: |
|---|
| 85 | void reloaded(); |
|---|
| 86 | void notifyWeaponModes(); |
|---|
| [2049] | 87 | |
|---|
| [2914] | 88 | WeaponPack* weaponPack_; |
|---|
| [2918] | 89 | WeaponSlot* weaponSlot_; |
|---|
| 90 | std::multimap<unsigned int, WeaponMode*> weaponmodes_; |
|---|
| [2096] | 91 | |
|---|
| [5929] | 92 | Timer reloadTimer_; |
|---|
| [2918] | 93 | bool bReloading_; |
|---|
| 94 | unsigned int reloadingWeaponmode_; |
|---|
| [2049] | 95 | }; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| [2106] | 98 | #endif /* _Weapon_H__ */ |
|---|