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