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/SubclassIdentifier.h" |
---|
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 | // 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 | ////////////////////me, copied to projectile.cc |
---|
110 | |
---|
111 | inline void setHealthDamage(float healthdamage) |
---|
112 | { this->healthdamage_ = healthdamage; } |
---|
113 | inline float getHealthDamage() const |
---|
114 | { return this->healthdamage_; } |
---|
115 | |
---|
116 | inline void setShieldDamage(float shielddamage) |
---|
117 | { this->shielddamage_ = shielddamage;} |
---|
118 | inline float getShieldDamage() const |
---|
119 | { return this->shielddamage_; } |
---|
120 | |
---|
121 | ///////////////////end me |
---|
122 | inline void setMuzzleOffset(const Vector3& offset) |
---|
123 | { this->muzzleOffset_ = offset; } |
---|
124 | inline const Vector3& getMuzzleOffset() const |
---|
125 | { return this->muzzleOffset_; } |
---|
126 | |
---|
127 | void computeMuzzleParameters(const Vector3& target); |
---|
128 | const Vector3& getMuzzlePosition() const |
---|
129 | { return this->muzzlePosition_; } |
---|
130 | const Quaternion& getMuzzleOrientation() const |
---|
131 | { return this->muzzleOrientation_; } |
---|
132 | Vector3 getMuzzleDirection() const; |
---|
133 | |
---|
134 | |
---|
135 | // Weapon |
---|
136 | inline void setWeapon(Weapon* weapon) |
---|
137 | { this->weapon_ = weapon; this->updateMunition(); } |
---|
138 | inline Weapon* getWeapon() const |
---|
139 | { return this->weapon_; } |
---|
140 | |
---|
141 | inline void setMode(unsigned int mode) |
---|
142 | { this->mode_ = mode; } |
---|
143 | inline unsigned int getMode() const |
---|
144 | { return this->mode_; } |
---|
145 | |
---|
146 | Vector3 getTarget(); |
---|
147 | |
---|
148 | protected: |
---|
149 | virtual void fire() = 0; |
---|
150 | |
---|
151 | unsigned int initialMunition_; |
---|
152 | unsigned int initialMagazines_; |
---|
153 | unsigned int munitionPerShot_; |
---|
154 | |
---|
155 | float reloadTime_; |
---|
156 | bool bAutoReload_; |
---|
157 | bool bParallelReload_; |
---|
158 | |
---|
159 | float damage_; |
---|
160 | float healthdamage_; |
---|
161 | float shielddamage_; |
---|
162 | Vector3 muzzleOffset_; |
---|
163 | |
---|
164 | private: |
---|
165 | void updateMunition(); |
---|
166 | void reloaded(); |
---|
167 | |
---|
168 | Weapon* weapon_; |
---|
169 | unsigned int mode_; |
---|
170 | |
---|
171 | Munition* munition_; |
---|
172 | SubclassIdentifier<Munition> munitiontype_; |
---|
173 | std::string munitionname_; |
---|
174 | |
---|
175 | Timer reloadTimer_; |
---|
176 | bool bReloading_; |
---|
177 | |
---|
178 | Vector3 muzzlePosition_; |
---|
179 | Quaternion muzzleOrientation_; |
---|
180 | |
---|
181 | WorldSound* defSndWpnFire_; |
---|
182 | bool bSoundAttached_; |
---|
183 | }; |
---|
184 | } |
---|
185 | |
---|
186 | #endif /* _WeaponMode_H__ */ |
---|