Orxonox  0.0.5 Codename: Arcturus
Weapon.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  * 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"
38 
39 namespace orxonox
40 {
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 
68  inline void setWeaponPack(WeaponPack * weaponPack)
69  { this->weaponPack_ = weaponPack; this->notifyWeaponModes(); }
70  inline WeaponPack * getWeaponPack() const
71  { return this->weaponPack_; }
72 
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 
89  std::multimap<unsigned int, WeaponMode*> weaponmodes_;
90 
93  unsigned int reloadingWeaponmode_;
94  };
95 }
96 
97 #endif /* _Weapon_H__ */
The a WeaponSlot defines where a Weapon is placed on a pawn.
Definition: WeaponSlot.h:59
The StaticEntity is the simplest derivative of the orxonox::WorldEntity class.
Definition: StaticEntity.h:50
Timer reloadTimer_
Definition: Weapon.h:91
bool bReloading_
Definition: Weapon.h:92
WeaponPack * getWeaponPack() const
Definition: Weapon.h:70
WeaponPack * weaponPack_
Definition: Weapon.h:87
WeaponSlot * getWeaponSlot() const
Definition: Weapon.h:79
void setWeaponSlot(WeaponSlot *wSlot)
This function is called by a orxonox::WeaponSlot if this Weapon gets attached to the WeaponSlot...
Definition: Weapon.h:77
xmlelement
Definition: Super.h:519
A WeaponMode defines how a Weapon is used.
Definition: WeaponMode.h:49
Declaration of the Timer class, used to call functions after a given time-interval.
WeaponSlot * weaponSlot_
Definition: Weapon.h:88
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
unsigned int reloadingWeaponmode_
Definition: Weapon.h:93
Mode
Definition: CorePrereqs.h:102
Definition: WeaponPack.h:40
A Weapon is a StaticEntity that can be attached to a WeaponSlot.
Definition: Weapon.h:46
const std::multimap< unsigned int, WeaponMode * > & getAllWeaponmodes() const
Definition: Weapon.h:59
Shared library macros, enums, constants and forward declarations for the orxonox library ...
Definition: Context.h:45
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
int getNumWeaponModes() const
Definition: Weapon.h:61
Timer is a helper class that executes a function after a given amount of seconds in game-time...
Definition: Timer.h:105
void setWeaponPack(WeaponPack *weaponPack)
This function is called by a orxonox::WeaponPack if this Weapon is added to the WeaponPack.
Definition: Weapon.h:68
std::multimap< unsigned int, WeaponMode * > weaponmodes_
Definition: Weapon.h:89