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 | * Fabian 'x3n' Landau |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef _Pawn_H__ |
---|
30 | #define _Pawn_H__ |
---|
31 | |
---|
32 | #include "OrxonoxPrereqs.h" |
---|
33 | |
---|
34 | #include <string> |
---|
35 | #include "interfaces/RadarViewable.h" |
---|
36 | #include "worldentities/ControllableEntity.h" |
---|
37 | #include "pickup/PickupCollection.h" |
---|
38 | |
---|
39 | namespace orxonox |
---|
40 | { |
---|
41 | class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable |
---|
42 | { |
---|
43 | friend class WeaponSystem; |
---|
44 | |
---|
45 | public: |
---|
46 | Pawn(BaseObject* creator); |
---|
47 | virtual ~Pawn(); |
---|
48 | |
---|
49 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
50 | virtual void tick(float dt); |
---|
51 | |
---|
52 | inline bool isAlive() const |
---|
53 | { return this->bAlive_; } |
---|
54 | |
---|
55 | virtual void setHealth(float health); |
---|
56 | inline void addHealth(float health) |
---|
57 | { this->setHealth(this->health_ + health); } |
---|
58 | inline void removeHealth(float health) |
---|
59 | { this->setHealth(this->health_ - health); } |
---|
60 | inline float getHealth() const |
---|
61 | { return this->health_; } |
---|
62 | |
---|
63 | inline void setMaxHealth(float maxhealth) |
---|
64 | { this->maxHealth_ = maxhealth; this->setHealth(this->health_); } |
---|
65 | inline float getMaxHealth() const |
---|
66 | { return this->maxHealth_; } |
---|
67 | |
---|
68 | inline void setInitialHealth(float initialhealth) |
---|
69 | { this->initialHealth_ = initialhealth; this->setHealth(initialhealth); } |
---|
70 | inline float getInitialHealth() const |
---|
71 | { return this->initialHealth_; } |
---|
72 | |
---|
73 | inline ControllableEntity* getLastHitOriginator() const |
---|
74 | { return this->lastHitOriginator_; } |
---|
75 | |
---|
76 | virtual void hit(Pawn* originator, const Vector3& force, float damage); |
---|
77 | virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); |
---|
78 | virtual void kill(); |
---|
79 | |
---|
80 | virtual void fired(unsigned int firemode); |
---|
81 | virtual void reload(); |
---|
82 | virtual void postSpawn(); |
---|
83 | |
---|
84 | void addWeaponSlot(WeaponSlot * wSlot); |
---|
85 | WeaponSlot * getWeaponSlot(unsigned int index) const; |
---|
86 | void addWeaponSet(WeaponSet * wSet); |
---|
87 | WeaponSet * getWeaponSet(unsigned int index) const; |
---|
88 | void addWeaponPack(WeaponPack * wPack); |
---|
89 | void addWeaponPackXML(WeaponPack * wPack); |
---|
90 | WeaponPack * getWeaponPack(unsigned int index) const; |
---|
91 | |
---|
92 | inline const WorldEntity* getWorldEntity() const |
---|
93 | { return const_cast<Pawn*>(this); } |
---|
94 | |
---|
95 | inline void setSpawnParticleSource(const std::string& source) |
---|
96 | { this->spawnparticlesource_ = source; } |
---|
97 | inline const std::string& getSpawnParticleSource() const |
---|
98 | { return this->spawnparticlesource_; } |
---|
99 | |
---|
100 | inline void setSpawnParticleDuration(float duration) |
---|
101 | { this->spawnparticleduration_ = duration; } |
---|
102 | inline float getSpawnParticleDuration() const |
---|
103 | { return this->spawnparticleduration_; } |
---|
104 | |
---|
105 | inline void setExplosionChunks(unsigned int chunks) |
---|
106 | { this->numexplosionchunks_ = chunks; } |
---|
107 | inline unsigned int getExplosionChunks() const |
---|
108 | { return this->numexplosionchunks_; } |
---|
109 | |
---|
110 | virtual void dropItems(); |
---|
111 | inline PickupCollection& getPickups() |
---|
112 | { return this->pickups_; } |
---|
113 | virtual void useItem() |
---|
114 | { this->pickups_.useItem(); } |
---|
115 | |
---|
116 | virtual void startLocalHumanControl(); |
---|
117 | |
---|
118 | void setAimPosition( Vector3 position ) |
---|
119 | { this->aimPosition_ = position; } |
---|
120 | Vector3 getAimPosition() |
---|
121 | { return this->aimPosition_; } |
---|
122 | |
---|
123 | protected: |
---|
124 | virtual void setPlayer(PlayerInfo* player); |
---|
125 | virtual void removePlayer(); |
---|
126 | |
---|
127 | virtual void death(); |
---|
128 | virtual void goWithStyle(); |
---|
129 | virtual void deatheffect(); |
---|
130 | virtual void spawneffect(); |
---|
131 | |
---|
132 | virtual void damage(float damage, Pawn* originator = 0); |
---|
133 | |
---|
134 | bool bAlive_; |
---|
135 | |
---|
136 | PickupCollection pickups_; |
---|
137 | |
---|
138 | float health_; |
---|
139 | float maxHealth_; |
---|
140 | float initialHealth_; |
---|
141 | |
---|
142 | Pawn* lastHitOriginator_; |
---|
143 | |
---|
144 | WeaponSystem* weaponSystem_; |
---|
145 | bool bReload_; |
---|
146 | |
---|
147 | std::string spawnparticlesource_; |
---|
148 | float spawnparticleduration_; |
---|
149 | unsigned int numexplosionchunks_; |
---|
150 | |
---|
151 | private: |
---|
152 | void registerVariables(); |
---|
153 | inline void setWeaponSystem(WeaponSystem* weaponsystem) |
---|
154 | { this->weaponSystem_ = weaponsystem; } |
---|
155 | |
---|
156 | Vector3 aimPosition_; |
---|
157 | }; |
---|
158 | } |
---|
159 | |
---|
160 | #endif /* _Pawn_H__ */ |
---|