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