Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

The weapon system HUD rescales properly if the window size changes.

  • Property svn:eol-style set to native
File size: 3.9 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    namespace MunitionDeployment
42    {
43        enum Value
44        {
45            Share,
46            Stack,
47            Separate
48        };
49    }
50
51    class _OrxonoxExport Munition : public BaseObject
52    {       
53        struct Magazine
54        {
55            public:
56                Magazine(Munition* munition, bool bUseReloadTime = true);
57                virtual ~Magazine() {}
58
59                unsigned int munition_;
60                Timer loadTimer_;
61                bool bLoaded_;
62
63            private:
64                void loaded(Munition* munition);
65        };
66
67        public:
68            Munition(Context* context);
69            virtual ~Munition();
70
71            unsigned int getNumMunition(WeaponMode* user) const;
72            unsigned int getNumMunitionInCurrentMagazine(WeaponMode* user) const;
73            unsigned int getNumMagazines() const;
74
75            unsigned int getMaxMunition() const;
76            inline unsigned int getMaxMagazines() const
77                { return this->maxMagazines_; }
78            inline unsigned int getMaxMunitionPerMagazine() const
79                { return this->maxMunitionPerMagazine_; }
80            inline MunitionDeployment::Value getMunitionDeployment() const
81                { return deployment_; }
82
83
84            bool canTakeMunition(unsigned int amount, WeaponMode* user) const;
85            bool takeMunition(unsigned int amount, WeaponMode* user);
86
87            bool canReload() const;
88            bool needReload(WeaponMode* user) const;
89            bool reload(WeaponMode* user, bool bUseReloadTime = true);
90            inline float getReloadTime() const
91                { return this->reloadTime_; }
92
93            bool canAddMunition(unsigned int amount) const;
94            bool addMunition(unsigned int amount);
95
96            bool canAddMagazines(unsigned int amount) const;
97            bool addMagazines(unsigned int amount);
98
99            bool canRemoveMagazines(unsigned int amount) const;
100            bool removeMagazines(unsigned int amount);
101
102            bool dropMagazine(WeaponMode* user);
103
104        protected:
105            unsigned int maxMunitionPerMagazine_;
106            unsigned int maxMagazines_;
107            unsigned int magazines_;
108            std::map<WeaponMode*, Magazine*> currentMagazines_; // Maps weapon modes to magazines that are currently used.
109
110            MunitionDeployment::Value deployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes.
111
112            bool bAllowMunitionRefilling_;
113            bool bAllowMultiMunitionRemovementUnderflow_;
114
115            float reloadTime_;
116            WeaponMode* lastFilledWeaponMode_; // Pointer to the weapon mode that got the last munition during the last call of addMunition.
117
118        private:
119            Magazine* getMagazine(WeaponMode* user) const;
120    };
121}
122
123#endif /* _Munition_H__ */
Note: See TracBrowser for help on using the repository browser.