[2918] | 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 | * Fabian 'x3n' Landau |
---|
| 25 | * Co-authors: |
---|
| 26 | * ... |
---|
| 27 | * |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | #ifndef _WeaponMode_H__ |
---|
| 31 | #define _WeaponMode_H__ |
---|
| 32 | |
---|
| 33 | #include "OrxonoxPrereqs.h" |
---|
| 34 | #include "core/BaseObject.h" |
---|
| 35 | |
---|
| 36 | #include "tools/Timer.h" |
---|
| 37 | #include "core/Identifier.h" |
---|
| 38 | #include "util/Math.h" |
---|
| 39 | |
---|
| 40 | namespace orxonox |
---|
| 41 | { |
---|
| 42 | class _OrxonoxExport WeaponMode : public BaseObject |
---|
| 43 | { |
---|
| 44 | public: |
---|
| 45 | WeaponMode(BaseObject* creator); |
---|
| 46 | virtual ~WeaponMode(); |
---|
| 47 | |
---|
| 48 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 49 | |
---|
| 50 | bool fire(float* reloadTime); |
---|
| 51 | bool reload(); |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | // Munition |
---|
| 55 | inline Munition* getMunition() const |
---|
| 56 | { return this->munition_; } |
---|
| 57 | |
---|
| 58 | void setMunitionType(Identifier* identifier); |
---|
| 59 | inline Identifier* getMunitionType() const |
---|
| 60 | { return this->munitiontype_; } |
---|
| 61 | |
---|
| 62 | void setMunitionName(const std::string& munitionname); |
---|
| 63 | inline const std::string& getMunitionName() const |
---|
| 64 | { return this->munitionname_; } |
---|
| 65 | |
---|
| 66 | inline void setInitialMunition(unsigned int amount) |
---|
| 67 | { this->initialMunition_ = amount; } |
---|
| 68 | inline unsigned int getInitialMunition() const |
---|
| 69 | { return this->initialMunition_; } |
---|
| 70 | |
---|
| 71 | inline void setInitialMagazines(unsigned int amount) |
---|
| 72 | { this->initialMagazines_ = amount; } |
---|
| 73 | inline unsigned int getInitialMagazines() const |
---|
| 74 | { return this->initialMagazines_; } |
---|
| 75 | |
---|
| 76 | inline void setMunitionPerShot(unsigned int amount) |
---|
| 77 | { this->munitionPerShot_ = amount; } |
---|
| 78 | inline unsigned int getMunitionPerShot() const |
---|
| 79 | { return this->munitionPerShot_; } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | // Reloading |
---|
| 83 | inline void setReloadTime(float time) |
---|
| 84 | { this->reloadTime_ = time; } |
---|
| 85 | inline float getReloadTime() const |
---|
| 86 | { return this->reloadTime_; } |
---|
| 87 | |
---|
| 88 | inline void setAutoReload(bool autoreload) |
---|
| 89 | { this->bAutoReload_ = autoreload; } |
---|
| 90 | inline bool getAutoReload() const |
---|
| 91 | { return this->bAutoReload_; } |
---|
| 92 | |
---|
| 93 | inline void setParallelReload(bool parallelreload) |
---|
| 94 | { this->bParallelReload_ = parallelreload; } |
---|
| 95 | inline bool getParallelReload() const |
---|
| 96 | { return this->bParallelReload_; } |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | // Fire |
---|
| 100 | inline void setDamage(float damage) |
---|
| 101 | { this->damage_ = damage; } |
---|
| 102 | inline float getDamage() const |
---|
| 103 | { return this->damage_; } |
---|
| 104 | |
---|
| 105 | inline void setMuzzleOffset(const Vector3& offset) |
---|
| 106 | { this->muzzleOffset_ = offset; } |
---|
| 107 | inline const Vector3& getMuzzleOffset() const |
---|
| 108 | { return this->muzzleOffset_; } |
---|
| 109 | |
---|
| 110 | Vector3 getMuzzlePosition() const; |
---|
| 111 | const Quaternion& getMuzzleOrientation() const; |
---|
| 112 | Vector3 getMuzzleDirection() const; |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | // Weapon |
---|
| 116 | inline void setWeapon(Weapon* weapon) |
---|
| 117 | { this->weapon_ = weapon; this->updateMunition(); } |
---|
| 118 | inline Weapon* getWeapon() const |
---|
| 119 | { return this->weapon_; } |
---|
| 120 | |
---|
| 121 | inline void setMode(unsigned int mode) |
---|
| 122 | { this->mode_ = mode; } |
---|
| 123 | inline unsigned int getMode() const |
---|
| 124 | { return this->mode_; } |
---|
| 125 | |
---|
| 126 | protected: |
---|
| 127 | virtual void fire() = 0; |
---|
| 128 | |
---|
| 129 | unsigned int initialMunition_; |
---|
| 130 | unsigned int initialMagazines_; |
---|
| 131 | unsigned int munitionPerShot_; |
---|
| 132 | |
---|
| 133 | float reloadTime_; |
---|
| 134 | bool bAutoReload_; |
---|
| 135 | bool bParallelReload_; |
---|
| 136 | |
---|
| 137 | float damage_; |
---|
| 138 | Vector3 muzzleOffset_; |
---|
| 139 | |
---|
| 140 | private: |
---|
| 141 | void updateMunition(); |
---|
| 142 | void reloaded(); |
---|
| 143 | |
---|
| 144 | Weapon* weapon_; |
---|
| 145 | unsigned int mode_; |
---|
| 146 | |
---|
| 147 | Munition* munition_; |
---|
| 148 | SubclassIdentifier<Munition> munitiontype_; |
---|
| 149 | std::string munitionname_; |
---|
| 150 | |
---|
| 151 | Timer<WeaponMode> reloadTimer_; |
---|
| 152 | bool bReloading_; |
---|
| 153 | }; |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | #endif /* _WeaponMode_H__ */ |
---|