[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 | |
---|
| 54 | |
---|
| 55 | // Munition |
---|
| 56 | inline Munition* getMunition() const |
---|
| 57 | { return this->munition_; } |
---|
| 58 | |
---|
| 59 | void setMunitionType(Identifier* identifier); |
---|
| 60 | inline Identifier* getMunitionType() const |
---|
| 61 | { return this->munitiontype_; } |
---|
| 62 | |
---|
| 63 | void setMunitionName(const std::string& munitionname); |
---|
| 64 | inline const std::string& getMunitionName() const |
---|
| 65 | { return this->munitionname_; } |
---|
| 66 | |
---|
| 67 | inline void setInitialMunition(unsigned int amount) |
---|
| 68 | { this->initialMunition_ = amount; } |
---|
| 69 | inline unsigned int getInitialMunition() const |
---|
| 70 | { return this->initialMunition_; } |
---|
| 71 | |
---|
| 72 | inline void setInitialMagazines(unsigned int amount) |
---|
| 73 | { this->initialMagazines_ = amount; } |
---|
| 74 | inline unsigned int getInitialMagazines() const |
---|
| 75 | { return this->initialMagazines_; } |
---|
| 76 | |
---|
| 77 | inline void setMunitionPerShot(unsigned int amount) |
---|
| 78 | { this->munitionPerShot_ = amount; } |
---|
| 79 | inline unsigned int getMunitionPerShot() const |
---|
| 80 | { return this->munitionPerShot_; } |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | // Reloading |
---|
| 84 | inline void setReloadTime(float time) |
---|
| 85 | { this->reloadTime_ = time; } |
---|
| 86 | inline float getReloadTime() const |
---|
| 87 | { return this->reloadTime_; } |
---|
| 88 | |
---|
| 89 | inline void setAutoReload(bool autoreload) |
---|
| 90 | { this->bAutoReload_ = autoreload; } |
---|
| 91 | inline bool getAutoReload() const |
---|
| 92 | { return this->bAutoReload_; } |
---|
| 93 | |
---|
| 94 | inline void setParallelReload(bool parallelreload) |
---|
| 95 | { this->bParallelReload_ = parallelreload; } |
---|
| 96 | inline bool getParallelReload() const |
---|
| 97 | { return this->bParallelReload_; } |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | // Fire |
---|
| 101 | inline void setDamage(float damage) |
---|
| 102 | { this->damage_ = damage; } |
---|
| 103 | inline float getDamage() const |
---|
| 104 | { return this->damage_; } |
---|
| 105 | |
---|
| 106 | inline void setMuzzleOffset(const Vector3& offset) |
---|
| 107 | { this->muzzleOffset_ = offset; } |
---|
| 108 | inline const Vector3& getMuzzleOffset() const |
---|
| 109 | { return this->muzzleOffset_; } |
---|
| 110 | |
---|
| 111 | Vector3 getMuzzlePosition() const; |
---|
| 112 | const Quaternion& getMuzzleOrientation() const; |
---|
| 113 | Vector3 getMuzzleDirection() const; |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | // Weapon |
---|
| 117 | inline void setWeapon(Weapon* weapon) |
---|
| 118 | { this->weapon_ = weapon; this->updateMunition(); } |
---|
| 119 | inline Weapon* getWeapon() const |
---|
| 120 | { return this->weapon_; } |
---|
| 121 | |
---|
| 122 | inline void setMode(unsigned int mode) |
---|
| 123 | { this->mode_ = mode; } |
---|
| 124 | inline unsigned int getMode() const |
---|
| 125 | { return this->mode_; } |
---|
| 126 | |
---|
| 127 | protected: |
---|
| 128 | virtual void fire() = 0; |
---|
| 129 | |
---|
| 130 | unsigned int initialMunition_; |
---|
| 131 | unsigned int initialMagazines_; |
---|
| 132 | unsigned int munitionPerShot_; |
---|
| 133 | |
---|
| 134 | float reloadTime_; |
---|
| 135 | bool bAutoReload_; |
---|
| 136 | bool bParallelReload_; |
---|
| 137 | |
---|
| 138 | float damage_; |
---|
| 139 | Vector3 muzzleOffset_; |
---|
| 140 | |
---|
| 141 | private: |
---|
| 142 | void updateMunition(); |
---|
| 143 | void reloaded(); |
---|
| 144 | |
---|
| 145 | Weapon* weapon_; |
---|
| 146 | unsigned int mode_; |
---|
| 147 | |
---|
| 148 | Munition* munition_; |
---|
| 149 | SubclassIdentifier<Munition> munitiontype_; |
---|
| 150 | std::string munitionname_; |
---|
| 151 | |
---|
[5929] | 152 | Timer reloadTimer_; |
---|
[2918] | 153 | bool bReloading_; |
---|
| 154 | }; |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | #endif /* _WeaponMode_H__ */ |
---|