Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h @ 3077

Last change on this file since 3077 was 3073, checked in by landauf, 15 years ago

merged pickups2 branch back to trunk. not yet tested.

  • Property svn:eol-style set to native
File size: 5.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#include "objects/worldentities/ControllableEntity.h"
34#include "objects/RadarViewable.h"
35#include "objects/pickup/PickupCollection.h"
36
37namespace orxonox
38{
39    class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable
40    {
41        friend class WeaponSystem;
42
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); }
59            inline float getHealth() const
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
79            virtual void fire(unsigned int firemode);
80            virtual void reload();
81            virtual void postSpawn();
82
83            void addWeaponSlot(WeaponSlot * wSlot);
84            WeaponSlot * getWeaponSlot(unsigned int index) const;
85            void addWeaponSet(WeaponSet * wSet);
86            WeaponSet * getWeaponSet(unsigned int index) const;
87            void addWeaponPack(WeaponPack * wPack);
88            WeaponPack * getWeaponPack(unsigned int index) const;
89
90            inline const WorldEntity* getWorldEntity() const
91                { return const_cast<Pawn*>(this); }
92
93            inline void setSpawnParticleSource(const std::string& source)
94                { this->spawnparticlesource_ = source; }
95            inline const std::string& getSpawnParticleSource() const
96                { return this->spawnparticlesource_; }
97
98            inline void setSpawnParticleDuration(float duration)
99                { this->spawnparticleduration_ = duration; }
100            inline float getSpawnParticleDuration() const
101                { return this->spawnparticleduration_; }
102
103            inline void setExplosionChunks(unsigned int chunks)
104                { this->numexplosionchunks_ = chunks; }
105            inline unsigned int getExplosionChunks() const
106                { return this->numexplosionchunks_; }
107
108            virtual void dropItems();
109            inline PickupCollection& getPickups()
110                { return this->pickups_; }
111            virtual void useItem()
112                { this->pickups_.useItem(); }
113
114        protected:
115            virtual void setPlayer(PlayerInfo* player);
116            virtual void removePlayer();
117
118            virtual void death();
119            virtual void deatheffect();
120            virtual void spawneffect();
121
122            bool bAlive_;
123
124            PickupCollection pickups_;
125
126            float health_;
127            float maxHealth_;
128            float initialHealth_;
129
130            Pawn* lastHitOriginator_;
131
132            WeaponSystem* weaponSystem_;
133            unsigned int fire_;
134            unsigned int firehack_;
135            bool bReload_;
136
137            std::string spawnparticlesource_;
138            float spawnparticleduration_;
139            unsigned int numexplosionchunks_;
140
141        private:
142            inline void setWeaponSystem(WeaponSystem* weaponsystem)
143                { this->weaponSystem_ = weaponsystem; }
144    };
145
146    class _OrxonoxExport PawnListener : virtual public OrxonoxClass
147    {
148        friend class Pawn;
149
150        public:
151            PawnListener();
152            virtual ~PawnListener() {}
153
154        protected:
155            virtual void destroyedPawn(Pawn* pawn) = 0;
156    };
157}
158
159#endif /* _Pawn_H__ */
Note: See TracBrowser for help on using the repository browser.