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