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 | * Reto Grieder |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | |
---|
30 | #ifndef _BaseWeapon_H__ |
---|
31 | #define _BaseWeapon_H__ |
---|
32 | |
---|
33 | #include "OrxonoxPrereqs.h" |
---|
34 | |
---|
35 | #include <OgrePrerequisites.h> |
---|
36 | |
---|
37 | #include "../Model.h" |
---|
38 | |
---|
39 | |
---|
40 | namespace orxonox { |
---|
41 | class _OrxonoxExport BaseWeapon : public Model |
---|
42 | { |
---|
43 | public: |
---|
44 | enum Action { |
---|
45 | NOTHING = 0, |
---|
46 | RELOAD = 1, |
---|
47 | CHANGE_AMMO = 2, |
---|
48 | SPECIAL = 3 |
---|
49 | }; |
---|
50 | |
---|
51 | protected: |
---|
52 | enum State { |
---|
53 | IDLE = 0, |
---|
54 | PRIMARY_FIRE = 1, |
---|
55 | SECONDARY_FIRE = 2, |
---|
56 | RELOADING = 3, |
---|
57 | CHANGING_AMMO = 4, |
---|
58 | }; |
---|
59 | |
---|
60 | public: |
---|
61 | BaseWeapon(); |
---|
62 | virtual ~BaseWeapon(); |
---|
63 | |
---|
64 | bool addAction(const Action); |
---|
65 | |
---|
66 | void primaryFireRequest(); |
---|
67 | |
---|
68 | void secondaryFireRequest(); |
---|
69 | |
---|
70 | int getAmmoState(); |
---|
71 | |
---|
72 | void setAmmoDump(AmmunitionDump*); |
---|
73 | |
---|
74 | virtual void tick(float dt); |
---|
75 | |
---|
76 | protected: |
---|
77 | virtual void primaryFire() = 0; |
---|
78 | |
---|
79 | virtual void primaryFiring(float) = 0; |
---|
80 | |
---|
81 | virtual void secondaryFire() = 0; |
---|
82 | |
---|
83 | virtual void secondaryFiring(float) = 0; |
---|
84 | |
---|
85 | virtual void registerAllVariables() { }; |
---|
86 | |
---|
87 | public: |
---|
88 | |
---|
89 | protected: |
---|
90 | Ogre::SceneManager *sceneMgr_; |
---|
91 | |
---|
92 | int bulletCounter_; |
---|
93 | BulletManager *bulletManager_; |
---|
94 | |
---|
95 | AmmunitionDump *ammoDump_; |
---|
96 | |
---|
97 | bool primaryFireRequest_; |
---|
98 | bool secondaryFireRequest_; |
---|
99 | |
---|
100 | float totalTime_; |
---|
101 | float actionStartTime_; |
---|
102 | |
---|
103 | State currentState_; |
---|
104 | bool secondaryFired_; |
---|
105 | |
---|
106 | Action nextAction_; |
---|
107 | bool actionAdded_; |
---|
108 | float timeSinceNextActionAdded_; |
---|
109 | static float nextActionValidityPeriod_s; |
---|
110 | |
---|
111 | // weapon properties |
---|
112 | int leftAmmo_; |
---|
113 | float primaryFirePower_; |
---|
114 | float secondaryFirePower_; |
---|
115 | float primaryFiringRate_; |
---|
116 | float secondaryFiringRate_; |
---|
117 | Real primaryBulletSpeed_; |
---|
118 | Real secondaryBulletSpeed_; |
---|
119 | |
---|
120 | int magazineSize_; |
---|
121 | |
---|
122 | }; |
---|
123 | } |
---|
124 | |
---|
125 | #endif /* _BaseWeapon_H__ */ |
---|