Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/src/orxonox/weaponsystem/Munition.h @ 6514

Last change on this file since 6514 was 5929, checked in by rgrieder, 15 years ago

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

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