Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/weaponsystem/WeaponSystem.h @ 11044

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

There is now a spaceship that uses the gravity bomb. Minor documentation improvements.

  • Property svn:eol-style set to native
File size: 3.6 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 *   Co-authors:
25 *      ...
26 *
27 */
28
29
30#ifndef _WeaponSystem_H__
31#define _WeaponSystem_H__
32
33#include "OrxonoxPrereqs.h"
34
35#include <map>
36#include <set>
37#include <vector>
38#include "core/BaseObject.h"
39
40namespace orxonox
41{
42    /**
43    @brief
44        An @ref orxonox::Pawn that is able to fire weapons always need to have a WeaponSystem. The WeaponSystem manages all the @ref orxonox::WeaponSet, @ref orxonox::WeaponPack and @ref orxonox::WeaponSlot classes.
45       
46    */       
47    class _OrxonoxExport WeaponSystem : public BaseObject
48    {
49        public:
50            WeaponSystem(Context* context);
51            virtual ~WeaponSystem();
52
53            // adding and removing WeaponSlots
54            void addWeaponSlot(WeaponSlot * wSlot);
55            void removeWeaponSlot(WeaponSlot * wSlot);
56            WeaponSlot * getWeaponSlot(unsigned int index) const;
57
58            // adding and removing WeaponSets
59            bool addWeaponSet(WeaponSet * wSet);
60            bool addWeaponSet(WeaponSet * wSet, unsigned int firemode);
61            void removeWeaponSet(WeaponSet * wSet);
62            WeaponSet * getWeaponSet(unsigned int index) const;
63
64            // adding and removing WeaponPacks
65            bool canAddWeaponPack(WeaponPack * wPack);
66            bool addWeaponPack(WeaponPack * wPack);
67            void removeWeaponPack(WeaponPack * wPack);
68            WeaponPack * getWeaponPack(unsigned int index) const;
69
70            // configure slots and firemodes
71            bool swapWeaponSlots(WeaponSlot * wSlot1, WeaponSlot * wSlot2);
72            void changeWeaponmode(WeaponPack * wPack, WeaponSet * wSet, unsigned int weaponmode);
73
74            void fire(unsigned int firemode);
75            void reload();
76
77            Munition * getMunition(SubclassIdentifier<Munition> * identifier);
78
79            inline void setPawn(Pawn * pawn)
80                { this->pawn_ = pawn; }
81            inline Pawn * getPawn() const
82                { return this->pawn_; }
83
84            inline int getWeaponSlotSize() const
85                { return this->weaponSlots_.size(); }
86
87            static inline unsigned int getFiremodeMask(unsigned int firemode)
88                { return (0x1 << firemode); }
89
90            static const unsigned int MAX_FIRE_MODES = 8;
91            static const unsigned int FIRE_MODE_UNASSIGNED = static_cast<unsigned int>(-1);
92
93            static const unsigned int MAX_WEAPON_MODES = 8;
94            static const unsigned int WEAPON_MODE_UNASSIGNED = static_cast<unsigned int>(-1);
95
96        private:
97            std::map<unsigned int, WeaponSet *> weaponSets_;
98            std::vector<WeaponSlot *> weaponSlots_;
99            std::vector<WeaponPack *> weaponPacks_;
100            std::map<Identifier *, Munition *> munitions_;
101            Pawn * pawn_;
102    };
103}
104
105#endif /* _WeaponSystem_H__ */
Note: See TracBrowser for help on using the repository browser.