Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationHS15/src/orxonox/weaponsystem/Munition.h @ 11053

Last change on this file since 11053 was 10961, checked in by maxima, 9 years ago

Merged presentation and fabiens branch. Had to modify hoverHUD and invaderHUD, because the text of the healthbar wasn't correctly displayed and the weapon settings of the hovership.

  • Property svn:eol-style set to native
File size: 5.1 KB
RevLine 
[2049]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 *
[2918]22 *   Authors:
[2049]23 *      Martin Polak
[2918]24 *      Fabian 'x3n' Landau
[2049]25 *   Co-authors:
[10961]26 *      Fabien Vultier
[2049]27 *
28 */
29
30#ifndef _Munition_H__
31#define _Munition_H__
32
33#include "OrxonoxPrereqs.h"
[2918]34
35#include <map>
[2049]36#include "core/BaseObject.h"
[2918]37#include "tools/Timer.h"
[2049]38
39namespace orxonox
40{
[10961]41    namespace MunitionDeployment
42    {
43        enum Value
44        {
45            Separate, // Every comsuming weapon mode has its own magazine. It is possible that one weapon mode is out of ammo while another still has some.
46            Share, // All comsuming weapon modes take their munition from the same magazine. If this magazine is empty a new one is loaded.
47            Stack // There is only one magazine where all the munition is stored. Use this deployment mode for heavy weapons loke rockets, bombs, ...
48        };
49    }
50
[2049]51    class _OrxonoxExport Munition : public BaseObject
[10961]52    {       
[2918]53        struct Magazine
54        {
55            public:
56                Magazine(Munition* munition, bool bUseReloadTime = true);
[7851]57                virtual ~Magazine() {}
[2918]58
59                unsigned int munition_;
[5929]60                Timer loadTimer_;
[2918]61                bool bLoaded_;
62
63            private:
64                void loaded(Munition* munition);
65        };
66
[2049]67        public:
[9667]68            Munition(Context* context);
[2049]69            virtual ~Munition();
70
[10961]71            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
72
[2918]73            unsigned int getNumMunition(WeaponMode* user) const;
74            unsigned int getNumMunitionInCurrentMagazine(WeaponMode* user) const;
75            unsigned int getNumMagazines() const;
[2049]76
[2918]77            unsigned int getMaxMunition() const;
78            inline unsigned int getMaxMagazines() const
79                { return this->maxMagazines_; }
80            inline unsigned int getMaxMunitionPerMagazine() const
81                { return this->maxMunitionPerMagazine_; }
[10961]82            inline MunitionDeployment::Value getMunitionDeployment() const
83                { return deployment_; }
[2662]84
[10961]85
[2918]86            bool canTakeMunition(unsigned int amount, WeaponMode* user) const;
87            bool takeMunition(unsigned int amount, WeaponMode* user);
[2662]88
[2918]89            bool canReload() const;
90            bool needReload(WeaponMode* user) const;
91            bool reload(WeaponMode* user, bool bUseReloadTime = true);
92            inline float getReloadTime() const
93                { return this->reloadTime_; }
[2662]94
[2918]95            bool canAddMunition(unsigned int amount) const;
96            bool addMunition(unsigned int amount);
[2049]97
[2918]98            bool canAddMagazines(unsigned int amount) const;
[10961]99            /**
100            @brief Try to add magazines.
101            @param amount The amount of magazines tried to add.
102            @return The amount of magazines sucessfully added.
103            */
104            unsigned int addMagazines(unsigned int amount);
[2918]105
106            bool canRemoveMagazines(unsigned int amount) const;
107            bool removeMagazines(unsigned int amount);
108
109            bool dropMagazine(WeaponMode* user);
110
[2662]111        protected:
[2918]112            unsigned int maxMunitionPerMagazine_;
113            unsigned int maxMagazines_;
[10961]114            unsigned int unassignedMagazines_; // Number of magazines that are not assigned to a weapon mode. These are alway treated as full.
115            std::map<WeaponMode*, Magazine*> assignedMagazines_; // Maps weapon modes to magazines that are currently used.
[2918]116
[10961]117            MunitionDeployment::Value deployment_; // Defines the behaviour how munition and magazines are distributed to the consuming weapon modes.
118
[2918]119            bool bAllowMunitionRefilling_;
120            bool bAllowMultiMunitionRemovementUnderflow_;
121
[10961]122            float reloadTime_; // The time needed to replace a magazine by a new one.
123            WeaponMode* lastFilledWeaponMode_; // Pointer to the weapon mode that got the last munition during the last call of addMunition.
[2918]124
125        private:
126            Magazine* getMagazine(WeaponMode* user) const;
[10961]127            inline void setMaxMagazines(unsigned int maxMagazines)
128                { this->maxMagazines_ = maxMagazines; }
129            inline void setMaxMunitionPerMagazine(unsigned int maxMunitionPerMagazine)
130                { this->maxMunitionPerMagazine_ = maxMunitionPerMagazine; }
131            void setNumMagazines(unsigned int numMagazines);
[2049]132    };
133}
134
[2106]135#endif /* _Munition_H__ */
Note: See TracBrowser for help on using the repository browser.