Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/src/orxonox/worldentities/pawns/Pawn.h @ 8541

Last change on this file since 8541 was 7889, checked in by landauf, 14 years ago

hack-fix: overridden implementations of stopLocalHumanControl() were not called in multiplayer, which caused the "fire" command to not reset in Spectator

  • Property svn:eol-style set to native
File size: 6.3 KB
Line 
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
39namespace orxonox // tolua_export
40{ // tolua_export
41    class _OrxonoxExport Pawn // tolua_export
42        : public ControllableEntity, public RadarViewable, public PickupCarrier
43    { // tolua_export
44        friend class WeaponSystem;
45
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
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 void setShieldHealth(float shieldHealth)
75            { this->shieldHealth_ = shieldHealth; }
76            inline float getShieldHealth()
77            { return this->shieldHealth_; }
78
79            inline void setShieldAbsorption(float shieldAbsorption)
80            { this->shieldAbsorption_ = shieldAbsorption; }
81            inline float getShieldAbsorption()
82            { return this->shieldAbsorption_; }
83
84            inline ControllableEntity* getLastHitOriginator() const
85                { return this->lastHitOriginator_; }
86
87            virtual void hit(Pawn* originator, const Vector3& force, float damage);
88            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
89            virtual void kill();
90
91            virtual void fired(unsigned int firemode);
92            virtual void reload();
93            virtual void postSpawn();
94
95            void addWeaponSlot(WeaponSlot * wSlot);
96            WeaponSlot * getWeaponSlot(unsigned int index) const;
97            void addWeaponSet(WeaponSet * wSet);
98            WeaponSet * getWeaponSet(unsigned int index) const;
99            void addWeaponPack(WeaponPack * wPack);
100            void addWeaponPackXML(WeaponPack * wPack);
101            WeaponPack * getWeaponPack(unsigned int index) const;
102
103            virtual void addedWeaponPack(WeaponPack* wPack) {}
104
105            inline const WorldEntity* getWorldEntity() const
106                { return const_cast<Pawn*>(this); }
107
108            inline void setSpawnParticleSource(const std::string& source)
109                { this->spawnparticlesource_ = source; }
110            inline const std::string& getSpawnParticleSource() const
111                { return this->spawnparticlesource_; }
112
113            inline void setSpawnParticleDuration(float duration)
114                { this->spawnparticleduration_ = duration; }
115            inline float getSpawnParticleDuration() const
116                { return this->spawnparticleduration_; }
117
118            inline void setExplosionChunks(unsigned int chunks)
119                { this->numexplosionchunks_ = chunks; }
120            inline unsigned int getExplosionChunks() const
121                { return this->numexplosionchunks_; }
122
123            virtual void startLocalHumanControl();
124
125            void setAimPosition( Vector3 position )
126                { this->aimPosition_ = position; }
127            Vector3 getAimPosition()
128                { return this->aimPosition_; }
129
130            virtual const Vector3& getCarrierPosition(void) const
131                { return this->getWorldPosition(); };
132
133        protected:
134            virtual void preDestroy();
135
136            virtual void setPlayer(PlayerInfo* player);
137            virtual void removePlayer();
138
139            virtual void death();
140            virtual void goWithStyle();
141            virtual void deatheffect();
142            virtual void spawneffect();
143
144            virtual void damage(float damage, Pawn* originator = 0);
145
146            bool bAlive_;
147
148            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
149                { return new std::vector<PickupCarrier*>(); }
150            virtual PickupCarrier* getCarrierParent(void) const
151                { return NULL; }
152
153            float health_;
154            float maxHealth_;
155            float initialHealth_;
156            float shieldHealth_;
157            float shieldAbsorption_; // Has to be between 0 and 1
158
159            WeakPtr<Pawn> lastHitOriginator_;
160
161            WeaponSystem* weaponSystem_;
162            bool bReload_;
163
164            std::string spawnparticlesource_;
165            float spawnparticleduration_;
166            unsigned int numexplosionchunks_;
167
168        private:
169            void registerVariables();
170            inline void setWeaponSystem(WeaponSystem* weaponsystem)
171                { this->weaponSystem_ = weaponsystem; }
172
173            Vector3 aimPosition_;
174    }; // tolua_export
175} // tolua_export
176
177#endif /* _Pawn_H__ */
Note: See TracBrowser for help on using the repository browser.