Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/fabienHS15/src/orxonox/weaponsystem/Munition.h @ 10688

Last change on this file since 10688 was 10688, checked in by fvultier, 9 years ago

There is now a HUD that shows the status of the weapon system: all weapons, weapon modes and their munition. Progress bars show the progress of replenishing munition.

  • Property svn:eol-style set to native
File size: 3.7 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#include "core/BaseObject.h"
37#include "tools/Timer.h"
38
39namespace orxonox
40{
41    enum Deployment
42    {
43        DEPLOYMENT_SHARE,
44        DEPLOYMENT_STACK,
45        DEPLOYMENT_SEPARATE
46    };
47
48
49    class _OrxonoxExport Munition : public BaseObject
50    {       
51        struct Magazine
52        {
53            public:
54                Magazine(Munition* munition, bool bUseReloadTime = true);
55                virtual ~Magazine() {}
56
57                unsigned int munition_;
58                Timer loadTimer_;
59                bool bLoaded_;
60
61            private:
62                void loaded(Munition* munition);
63        };
64
65        public:
66            Munition(Context* context);
67            virtual ~Munition();
68
69            unsigned int getNumMunition(WeaponMode* user) const;
70            unsigned int getNumMunitionInCurrentMagazine(WeaponMode* user) const;
71            unsigned int getNumMagazines() const;
72
73            unsigned int getMaxMunition() const;
74            inline unsigned int getMaxMagazines() const
75                { return this->maxMagazines_; }
76            inline unsigned int getMaxMunitionPerMagazine() const
77                { return this->maxMunitionPerMagazine_; }
78            inline bool getUseSeparateMagazines() const
79                { return deployment_ == DEPLOYMENT_SEPARATE; }
80            inline bool getStackMunition() const
81                { return deployment_ == DEPLOYMENT_STACK; }
82
83            bool canTakeMunition(unsigned int amount, WeaponMode* user) const;
84            bool takeMunition(unsigned int amount, WeaponMode* user);
85
86            bool canReload() const;
87            bool needReload(WeaponMode* user) const;
88            bool reload(WeaponMode* user, bool bUseReloadTime = true);
89            inline float getReloadTime() const
90                { return this->reloadTime_; }
91
92            bool canAddMunition(unsigned int amount) const;
93            bool addMunition(unsigned int amount);
94
95            bool canAddMagazines(unsigned int amount) const;
96            bool addMagazines(unsigned int amount);
97
98            bool canRemoveMagazines(unsigned int amount) const;
99            bool removeMagazines(unsigned int amount);
100
101            bool dropMagazine(WeaponMode* user);
102
103        protected:
104            unsigned int maxMunitionPerMagazine_;
105            unsigned int maxMagazines_;
106            unsigned int magazines_;
107            std::map<WeaponMode*, Magazine*> currentMagazines_;
108
109            Deployment deployment_;
110
111            bool bAllowMunitionRefilling_;
112            bool bAllowMultiMunitionRemovementUnderflow_;
113
114            float reloadTime_;
115
116        private:
117            Magazine* getMagazine(WeaponMode* user) const;
118    };
119}
120
121#endif /* _Munition_H__ */
Note: See TracBrowser for help on using the repository browser.