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 | |
---|
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 | void computeMuzzleParameters(const Vector3& target); |
---|
112 | const Vector3& getMuzzlePosition() const |
---|
113 | { return this->muzzlePosition_; } |
---|
114 | const Quaternion& getMuzzleOrientation() const |
---|
115 | { return this->muzzleOrientation_; } |
---|
116 | Vector3 getMuzzleDirection() const; |
---|
117 | |
---|
118 | |
---|
119 | // Weapon |
---|
120 | inline void setWeapon(Weapon* weapon) |
---|
121 | { this->weapon_ = weapon; this->updateMunition(); } |
---|
122 | inline Weapon* getWeapon() const |
---|
123 | { return this->weapon_; } |
---|
124 | |
---|
125 | inline void setMode(unsigned int mode) |
---|
126 | { this->mode_ = mode; } |
---|
127 | inline unsigned int getMode() const |
---|
128 | { return this->mode_; } |
---|
129 | |
---|
130 | Vector3 getTarget(); |
---|
131 | |
---|
132 | protected: |
---|
133 | virtual void fire() = 0; |
---|
134 | |
---|
135 | unsigned int initialMunition_; |
---|
136 | unsigned int initialMagazines_; |
---|
137 | unsigned int munitionPerShot_; |
---|
138 | |
---|
139 | float reloadTime_; |
---|
140 | bool bAutoReload_; |
---|
141 | bool bParallelReload_; |
---|
142 | |
---|
143 | float damage_; |
---|
144 | Vector3 muzzleOffset_; |
---|
145 | |
---|
146 | private: |
---|
147 | void updateMunition(); |
---|
148 | void reloaded(); |
---|
149 | |
---|
150 | Weapon* weapon_; |
---|
151 | unsigned int mode_; |
---|
152 | |
---|
153 | Munition* munition_; |
---|
154 | SubclassIdentifier<Munition> munitiontype_; |
---|
155 | std::string munitionname_; |
---|
156 | |
---|
157 | Timer reloadTimer_; |
---|
158 | bool bReloading_; |
---|
159 | |
---|
160 | Vector3 muzzlePosition_; |
---|
161 | Quaternion muzzleOrientation_; |
---|
162 | }; |
---|
163 | } |
---|
164 | |
---|
165 | #endif /* _WeaponMode_H__ */ |
---|