[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 |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _Weapon_H__ |
---|
| 30 | #define _Weapon_H__ |
---|
| 31 | |
---|
| 32 | #include "OrxonoxPrereqs.h" |
---|
[2912] | 33 | #include "objects/worldentities/StaticEntity.h" |
---|
[2049] | 34 | |
---|
[2662] | 35 | #include "tools/Timer.h" |
---|
| 36 | #include "core/Identifier.h" |
---|
[2049] | 37 | |
---|
| 38 | namespace orxonox |
---|
| 39 | { |
---|
[2662] | 40 | class _OrxonoxExport Weapon : public StaticEntity |
---|
[2049] | 41 | { |
---|
| 42 | public: |
---|
[2097] | 43 | Weapon(BaseObject* creator); |
---|
[2049] | 44 | virtual ~Weapon(); |
---|
| 45 | |
---|
[2096] | 46 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 47 | |
---|
[2060] | 48 | virtual void fire(); |
---|
[2912] | 49 | void attachNeededMunition(const std::string& munitionType); |
---|
| 50 | Munition * getAttachedMunition(const std::string& munitiontype); |
---|
[2049] | 51 | |
---|
[2662] | 52 | //reloading |
---|
| 53 | void bulletTimer(float bulletLoadingTime); |
---|
| 54 | void magazineTimer(float magazineLoadingTime); |
---|
| 55 | void bulletReloaded(); |
---|
| 56 | void magazineReloaded(); |
---|
| 57 | |
---|
[2893] | 58 | //XMLPort functions |
---|
[2912] | 59 | virtual void setMunitionType(const std::string& munitionType); |
---|
| 60 | virtual const std::string& getMunitionType() const; |
---|
[2662] | 61 | virtual void setBulletLoadingTime(float loadingTime); |
---|
[2912] | 62 | virtual const float getBulletLoadingTime() const; |
---|
[2662] | 63 | virtual void setMagazineLoadingTime(float loadingTime); |
---|
[2912] | 64 | virtual const float getMagazineLoadingTime() const; |
---|
[2893] | 65 | virtual void setBulletAmount(unsigned int amount); |
---|
[2912] | 66 | virtual const unsigned int getBulletAmount() const; |
---|
[2893] | 67 | virtual void setMagazineAmount(unsigned int amount); |
---|
[2912] | 68 | virtual const unsigned int getMagazineAmount() const; |
---|
[2893] | 69 | virtual void setUnlimitedMunition(bool unlimitedMunition); |
---|
[2912] | 70 | virtual const bool getUnlimitedMunition() const; |
---|
[2662] | 71 | |
---|
[2893] | 72 | //weapon actions |
---|
[2662] | 73 | virtual void takeBullets(); |
---|
| 74 | virtual void takeMagazines(); |
---|
| 75 | virtual void createProjectile(); |
---|
[2893] | 76 | virtual void reloadBullet(); |
---|
| 77 | virtual void reloadMagazine(); |
---|
[2662] | 78 | |
---|
[2893] | 79 | //manually set or reset |
---|
| 80 | virtual void setWeapon(); |
---|
| 81 | virtual void setMunition(); |
---|
[2662] | 82 | |
---|
[2912] | 83 | inline void setWeaponSystem(WeaponSystem *weaponSystem) |
---|
| 84 | { this->weaponSystem_ = weaponSystem; }; |
---|
| 85 | inline WeaponSystem * getWeaponSystem() const |
---|
| 86 | { return this->weaponSystem_; }; |
---|
| 87 | |
---|
[2662] | 88 | inline void setAttachedToWeaponSlot(WeaponSlot * wSlot) |
---|
| 89 | { this->attachedToWeaponSlot_ = wSlot; } |
---|
[2912] | 90 | inline WeaponSlot * getAttachedToWeaponSlot() const |
---|
[2662] | 91 | { return this->attachedToWeaponSlot_; } |
---|
| 92 | |
---|
| 93 | protected: |
---|
| 94 | bool bReloading_; |
---|
| 95 | bool bulletReadyToShoot_; |
---|
| 96 | bool magazineReadyToShoot_; |
---|
[2893] | 97 | bool unlimitedMunition_; |
---|
[2662] | 98 | float bulletLoadingTime_; |
---|
| 99 | float magazineLoadingTime_; |
---|
[2893] | 100 | unsigned int bulletAmount_; |
---|
| 101 | unsigned int magazineAmount_; |
---|
[2662] | 102 | std::string munitionType_; |
---|
[2049] | 103 | |
---|
[2662] | 104 | WeaponSlot * attachedToWeaponSlot_; |
---|
| 105 | Munition * munition_; |
---|
[2912] | 106 | WeaponSystem * weaponSystem_; |
---|
[2096] | 107 | |
---|
[2662] | 108 | SubclassIdentifier<Munition> munitionIdentifier_; |
---|
| 109 | |
---|
| 110 | Timer<Weapon> bulletReloadTimer_; |
---|
| 111 | Timer<Weapon> magazineReloadTimer_; |
---|
[2049] | 112 | }; |
---|
| 113 | } |
---|
| 114 | |
---|
[2106] | 115 | #endif /* _Weapon_H__ */ |
---|