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 | #include "objects/pickup/ShipEquipment.h" |
---|
34 | #include "objects/worldentities/ControllableEntity.h" |
---|
35 | #include "objects/RadarViewable.h" |
---|
36 | #include "objects/weaponSystem/WeaponSystem.h" |
---|
37 | |
---|
38 | namespace orxonox |
---|
39 | { |
---|
40 | class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable |
---|
41 | { |
---|
42 | public: |
---|
43 | Pawn(BaseObject* creator); |
---|
44 | virtual ~Pawn(); |
---|
45 | |
---|
46 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
47 | virtual void tick(float dt); |
---|
48 | void registerVariables(); |
---|
49 | |
---|
50 | virtual void setPlayer(PlayerInfo* player); |
---|
51 | virtual void removePlayer(); |
---|
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 damage(float damage, Pawn* originator = 0); |
---|
78 | virtual void hit(Pawn* originator, const Vector3& force, float damage); |
---|
79 | virtual void kill(); |
---|
80 | |
---|
81 | virtual void fire(WeaponMode::Enum fireMode); |
---|
82 | virtual void doFire(uint8_t fireMode); |
---|
83 | virtual void postSpawn(); |
---|
84 | |
---|
85 | void setWeaponSlot(WeaponSlot * wSlot); |
---|
86 | WeaponSlot * getWeaponSlot(unsigned int index) const; |
---|
87 | void setWeaponPack(WeaponPack * wPack); |
---|
88 | WeaponPack * getWeaponPack(unsigned int firemode) const; |
---|
89 | void setWeaponSet(WeaponSet * wSet); |
---|
90 | WeaponSet * getWeaponSet(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 | inline ShipEquipment& getPickUp() |
---|
111 | {return this->pickUp;} |
---|
112 | |
---|
113 | virtual void dropItems(); |
---|
114 | |
---|
115 | protected: |
---|
116 | virtual void death(); |
---|
117 | virtual void deatheffect(); |
---|
118 | virtual void spawneffect(); |
---|
119 | |
---|
120 | ShipEquipment pickUp; |
---|
121 | bool bAlive_; |
---|
122 | |
---|
123 | |
---|
124 | float health_; |
---|
125 | float maxHealth_; |
---|
126 | float initialHealth_; |
---|
127 | |
---|
128 | Pawn* lastHitOriginator_; |
---|
129 | |
---|
130 | WeaponSystem* weaponSystem_; |
---|
131 | unsigned int fire_; |
---|
132 | unsigned int firehack_; |
---|
133 | |
---|
134 | std::string spawnparticlesource_; |
---|
135 | float spawnparticleduration_; |
---|
136 | unsigned int numexplosionchunks_; |
---|
137 | }; |
---|
138 | |
---|
139 | class _OrxonoxExport PawnListener : virtual public OrxonoxClass |
---|
140 | { |
---|
141 | friend class Pawn; |
---|
142 | |
---|
143 | public: |
---|
144 | PawnListener(); |
---|
145 | virtual ~PawnListener() {} |
---|
146 | |
---|
147 | protected: |
---|
148 | virtual void destroyedPawn(Pawn* pawn) = 0; |
---|
149 | }; |
---|
150 | } |
---|
151 | |
---|
152 | #endif /* _Pawn_H__ */ |
---|