Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ScriptableController_HS17/src/orxonox/weaponsystem/Weapon.h @ 11654

Last change on this file since 11654 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 3.2 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 *   Author:
23 *      Martin Polak
24 *      Fabian 'x3n' Landau
25 *   Co-authors:
26 *      ...
27 *
28 */
29
30#ifndef _Weapon_H__
31#define _Weapon_H__
32
33#include "OrxonoxPrereqs.h"
34
35#include <map>
36#include "tools/Timer.h"
37#include "worldentities/StaticEntity.h"
38
39namespace orxonox
40{
41    /**
42    @brief
43        A Weapon is a StaticEntity that can be attached to a WeaponSlot. A Weapon can shoot with different @ref orxonox::WeaponMode modes.
44        Imagine for example that a machine gun can shoot normal bullets, tracer bullets or even grenades.
45    */   
46    class _OrxonoxExport Weapon : public StaticEntity
47    {
48        public:
49            Weapon(Context* context);
50            virtual ~Weapon();
51
52            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
53
54            void fire(unsigned int mode);
55            void reload();
56
57            void addWeaponmode(WeaponMode* weaponmode);
58            WeaponMode* getWeaponmode(unsigned int index) const;
59            inline const std::multimap<unsigned int, WeaponMode*>& getAllWeaponmodes() const
60                { return weaponmodes_; }
61            inline int getNumWeaponModes() const
62                { return weaponmodes_.size(); }
63
64            /**
65            @brief
66                This function is called by a @ref orxonox::WeaponPack if this Weapon is added to the WeaponPack.
67            */
68            inline void setWeaponPack(WeaponPack * weaponPack)
69                { this->weaponPack_ = weaponPack; this->notifyWeaponModes(); }
70            inline WeaponPack * getWeaponPack() const
71                { return this->weaponPack_; }
72
73            /**
74            @brief
75                This function is called by a @ref orxonox::WeaponSlot if this Weapon gets attached to the WeaponSlot.
76            */
77            inline void setWeaponSlot(WeaponSlot * wSlot)
78                { this->weaponSlot_ = wSlot; }
79            inline WeaponSlot * getWeaponSlot() const
80                { return this->weaponSlot_; }
81            void updateMunition();
82
83        private:
84            void reloaded();
85            void notifyWeaponModes();
86
87            WeaponPack* weaponPack_;
88            WeaponSlot* weaponSlot_;
89            std::multimap<unsigned int, WeaponMode*> weaponmodes_;
90
91            Timer reloadTimer_;
92            bool bReloading_;
93            unsigned int reloadingWeaponmode_;
94    };
95}
96
97#endif /* _Weapon_H__ */
Note: See TracBrowser for help on using the repository browser.