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