Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weapons/src/orxonox/objects/weaponsystem/Munition.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: 3.4 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 *   Authors:
23 *      Martin Polak
24 *      Fabian 'x3n' Landau
25 *   Co-authors:
26 *      ...
27 *
28 */
29
30#ifndef _Munition_H__
31#define _Munition_H__
32
33#include "OrxonoxPrereqs.h"
34
35#include <map>
36
37#include "core/BaseObject.h"
38#include "tools/Timer.h"
39
40namespace orxonox
41{
42    class _OrxonoxExport Munition : public BaseObject
43    {
44        struct Magazine
45        {
46            public:
47                Magazine(Munition* munition, bool bUseReloadTime = true);
48
49                unsigned int munition_;
50                Timer<Magazine> loadTimer_;
51                bool bLoaded_;
52
53            private:
54                void loaded(Munition* munition);
55        };
56
57        public:
58            Munition(BaseObject* creator);
59            virtual ~Munition();
60
61            unsigned int getNumMunition(WeaponMode* user) const;
62            unsigned int getNumMunitionInCurrentMagazine(WeaponMode* user) const;
63            unsigned int getNumMagazines() const;
64
65            unsigned int getMaxMunition() const;
66            inline unsigned int getMaxMagazines() const
67                { return this->maxMagazines_; }
68            inline unsigned int getMaxMunitionPerMagazine() const
69                { return this->maxMunitionPerMagazine_; }
70
71            bool canTakeMunition(unsigned int amount, WeaponMode* user) const;
72            bool takeMunition(unsigned int amount, WeaponMode* user);
73
74            bool canReload() const;
75            bool needReload(WeaponMode* user) const;
76            bool reload(WeaponMode* user, bool bUseReloadTime = true);
77            inline float getReloadTime() const
78                { return this->reloadTime_; }
79
80            bool canAddMunition(unsigned int amount) const;
81            bool addMunition(unsigned int amount);
82
83            bool canAddMagazines(unsigned int amount) const;
84            bool addMagazines(unsigned int amount);
85
86            bool canRemoveMagazines(unsigned int amount) const;
87            bool removeMagazines(unsigned int amount);
88
89            bool dropMagazine(WeaponMode* user);
90
91        protected:
92            unsigned int maxMunitionPerMagazine_;
93            unsigned int maxMagazines_;
94            unsigned int magazines_;
95            std::map<WeaponMode*, Magazine*> currentMagazines_;
96
97            bool bUseSeparateMagazines_;
98            bool bStackMunition_;
99            bool bAllowMunitionRefilling_;
100            bool bAllowMultiMunitionRemovementUnderflow_;
101
102            float reloadTime_;
103
104        private:
105            Magazine* getMagazine(WeaponMode* user) const;
106    };
107}
108
109#endif /* _Munition_H__ */
Note: See TracBrowser for help on using the repository browser.