Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.h @ 3050

Last change on this file since 3050 was 2918, checked in by landauf, 16 years ago

Added many new features in the Munition class:

  • there are now 3 modes: a) every weapon has it's own magazine b) all weapons use the same magazin c) no magazines, just a big munition pool
  • the Munition class handles the reloading of the magazine

Split the Weapon class into Weapon and WeaponMode. WeaponMode creates the fire of the Weapon. A weapon can own several WeaponModes (for example primary and secondary fire). But it's also possible to have a weapon with several muzzles which all fire at the same time (there's a WeaponMode for each muzzle).

Renamed LaserGun to LaserFire and Fusion to FusionFire. They inherit now from WeaponMode.

Changed the code in the Weapon class to use the new Munition functionality.

Added ReplenishingMunition, a subclass of Munition that replenishes itself (used for LaserGunMunition).

Added a reload command to reload magazines.

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