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 | |
---|
35 | #include <string> |
---|
36 | #include "util/Math.h" |
---|
37 | #include "core/BaseObject.h" |
---|
38 | #include "core/class/SubclassIdentifier.h" |
---|
39 | #include "tools/Timer.h" |
---|
40 | |
---|
41 | namespace orxonox |
---|
42 | { |
---|
43 | class _OrxonoxExport WeaponMode : public BaseObject |
---|
44 | { |
---|
45 | public: |
---|
46 | WeaponMode(Context* context); |
---|
47 | virtual ~WeaponMode(); |
---|
48 | |
---|
49 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
50 | |
---|
51 | bool fire(float* reloadTime); |
---|
52 | bool reload(); |
---|
53 | |
---|
54 | // Interacting with the default Firing sound |
---|
55 | void setDefaultSound(const std::string& soundPath); |
---|
56 | const std::string& getDefaultSound(); |
---|
57 | void setDefaultSoundWithVolume(const std::string& soundPath, const float soundVolume); |
---|
58 | |
---|
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 | inline void setHealthDamage(float healthdamage) |
---|
110 | { this->healthdamage_ = healthdamage; } |
---|
111 | inline float getHealthDamage() const |
---|
112 | { return this->healthdamage_; } |
---|
113 | |
---|
114 | inline void setShieldDamage(float shielddamage) |
---|
115 | { this->shielddamage_ = shielddamage;} |
---|
116 | inline float getShieldDamage() const |
---|
117 | { return this->shielddamage_; } |
---|
118 | |
---|
119 | inline void setMuzzleOffset(const Vector3& offset) |
---|
120 | { this->muzzleOffset_ = offset; } |
---|
121 | inline const Vector3& getMuzzleOffset() const |
---|
122 | { return this->muzzleOffset_; } |
---|
123 | |
---|
124 | void computeMuzzleParameters(const Vector3& target); |
---|
125 | const Vector3& getMuzzlePosition() const |
---|
126 | { return this->muzzlePosition_; } |
---|
127 | const Quaternion& getMuzzleOrientation() const |
---|
128 | { return this->muzzleOrientation_; } |
---|
129 | Vector3 getMuzzleDirection() const; |
---|
130 | |
---|
131 | |
---|
132 | // Weapon |
---|
133 | inline void setWeapon(Weapon* weapon) |
---|
134 | { this->weapon_ = weapon; this->updateMunition(); } |
---|
135 | inline Weapon* getWeapon() const |
---|
136 | { return this->weapon_; } |
---|
137 | |
---|
138 | inline void setMode(unsigned int mode) |
---|
139 | { this->mode_ = mode; } |
---|
140 | inline unsigned int getMode() const |
---|
141 | { return this->mode_; } |
---|
142 | |
---|
143 | Vector3 getTarget(); |
---|
144 | |
---|
145 | protected: |
---|
146 | virtual void fire() = 0; |
---|
147 | |
---|
148 | unsigned int initialMunition_; |
---|
149 | unsigned int initialMagazines_; |
---|
150 | unsigned int munitionPerShot_; |
---|
151 | |
---|
152 | float reloadTime_; |
---|
153 | bool bAutoReload_; |
---|
154 | bool bParallelReload_; |
---|
155 | |
---|
156 | float damage_; |
---|
157 | float healthdamage_; |
---|
158 | float shielddamage_; |
---|
159 | Vector3 muzzleOffset_; |
---|
160 | |
---|
161 | private: |
---|
162 | void updateMunition(); |
---|
163 | void reloaded(); |
---|
164 | |
---|
165 | Weapon* weapon_; |
---|
166 | unsigned int mode_; |
---|
167 | |
---|
168 | Munition* munition_; |
---|
169 | SubclassIdentifier<Munition> munitiontype_; |
---|
170 | std::string munitionname_; |
---|
171 | |
---|
172 | Timer reloadTimer_; |
---|
173 | bool bReloading_; |
---|
174 | |
---|
175 | Vector3 muzzlePosition_; |
---|
176 | Quaternion muzzleOrientation_; |
---|
177 | |
---|
178 | WorldSound* defSndWpnFire_; |
---|
179 | bool bSoundAttached_; |
---|
180 | }; |
---|
181 | } |
---|
182 | |
---|
183 | #endif /* _WeaponMode_H__ */ |
---|