Orxonox  0.0.5 Codename: Arcturus
WeaponSystem.h
Go to the documentation of this file.
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 
40 namespace orxonox
41 {
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  inline const std::vector<WeaponSlot *>& getAllWeaponSlots() const
58  { return weaponSlots_; }
59 
60  // adding and removing WeaponSets
61  bool addWeaponSet(WeaponSet * wSet);
62  bool addWeaponSet(WeaponSet * wSet, unsigned int firemode);
63  void removeWeaponSet(WeaponSet * wSet);
64  WeaponSet * getWeaponSet(unsigned int index) const;
65 
66  // adding and removing WeaponPacks
67  bool canAddWeaponPack(WeaponPack * wPack);
68  bool addWeaponPack(WeaponPack * wPack);
69  void removeWeaponPack(WeaponPack * wPack);
70  WeaponPack * getWeaponPack(unsigned int index) const;
71  inline const std::vector<WeaponPack *>& getAllWeaponPacks() const
72  { return weaponPacks_; }
73 
74  // configure slots and firemodes
75  bool swapWeaponSlots(WeaponSlot * wSlot1, WeaponSlot * wSlot2);
76  void changeWeaponmode(WeaponPack * wPack, WeaponSet * wSet, unsigned int weaponmode);
77 
78  void fire(unsigned int firemode);
79  void reload();
80 
81  Munition * getMunition(SubclassIdentifier<Munition> * identifier);
82  void addMunition(Munition* munition);
83 
84  inline void setPawn(Pawn * pawn)
85  { this->pawn_ = pawn; }
86  inline Pawn * getPawn() const
87  { return this->pawn_; }
88 
89  inline int getWeaponSlotSize() const
90  { return this->weaponSlots_.size(); }
91 
92  static inline unsigned int getFiremodeMask(unsigned int firemode)
93  { return (0x1 << firemode); }
94 
95  static const unsigned int MAX_FIRE_MODES = 8;
96  static const unsigned int FIRE_MODE_UNASSIGNED = static_cast<unsigned int>(-1);
97 
98  static const unsigned int MAX_WEAPON_MODES = 8;
99  static const unsigned int WEAPON_MODE_UNASSIGNED = static_cast<unsigned int>(-1);
100 
101  private:
102  void updateMunition();
103 
104  std::map<unsigned int, WeaponSet *> weaponSets_;
105  std::vector<WeaponSlot *> weaponSlots_;
106  std::vector<WeaponPack *> weaponPacks_;
107  std::map<Identifier *, Munition *> munitions_;
109  };
110 }
111 
112 #endif /* _WeaponSystem_H__ */
The BaseObject is the parent of all classes representing an instance in the game. ...
Definition: BaseObject.h:63
Everything in Orxonox that has a health attribute is a Pawn.
Definition: Pawn.h:56
The a WeaponSlot defines where a Weapon is placed on a pawn.
Definition: WeaponSlot.h:59
void setPawn(Pawn *pawn)
Definition: WeaponSystem.h:84
Definition: Munition.h:48
std::map< unsigned int, WeaponSet * > weaponSets_
Definition: WeaponSystem.h:104
std::vector< WeaponSlot * > weaponSlots_
Definition: WeaponSystem.h:105
Definition: WeaponSet.h:40
std::map< Identifier *, Munition * > munitions_
Definition: WeaponSystem.h:107
An orxonox::Pawn that is able to fire weapons always need to have a WeaponSystem. ...
Definition: WeaponSystem.h:47
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
const std::vector< WeaponSlot * > & getAllWeaponSlots() const
Definition: WeaponSystem.h:57
Definition: WeaponPack.h:40
static unsigned int getFiremodeMask(unsigned int firemode)
Definition: WeaponSystem.h:92
Shared library macros, enums, constants and forward declarations for the orxonox library ...
int getWeaponSlotSize() const
Definition: WeaponSystem.h:89
Declaration of BaseObject, the base class of all objects in Orxonox.
Definition: Context.h:45
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
const std::vector< WeaponPack * > & getAllWeaponPacks() const
Definition: WeaponSystem.h:71
std::vector< WeaponPack * > weaponPacks_
Definition: WeaponSystem.h:106
Pawn * getPawn() const
Definition: WeaponSystem.h:86
The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.
Definition: SubclassIdentifier.h:90
Pawn * pawn_
Definition: WeaponSystem.h:108