Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/vs-enhencements/src/world_entities/weapons/weapon_slot.h @ 10676

Last change on this file since 10676 was 10676, checked in by nicolasc, 17 years ago

xfer

File size: 2.3 KB
Line 
1/*!
2 * @file weapon_slot.h
3 */
4
5
6#ifndef _WEAPON_SLOT_H
7#define _WEAPON_SLOT_H
8
9#include "p_node.h"
10#include "weapon.h"
11#include "weapon_manager.h"
12
13class Weapon;
14
15//! a class defining a Slot, where a Weapon can be stored inside.
16class WeaponSlot : public PNode
17{
18  ObjectListDeclaration(WeaponSlot);
19
20public:
21
22  WeaponSlot();
23  WeaponSlot(const TiXmlElement* root);
24  virtual ~WeaponSlot();
25
26  virtual void loadParams(const TiXmlElement* root);
27
28  void setWeaponClass();
29
30  long getCapability() { return this->capability; }
31  void setCapability(long cap) { this->capability = cap; }
32
33  inline Weapon* getCurrentWeapon() { return this->currentWeapon; }
34  inline void setCurrentWeapon(int config) { this->currentWeapon = this->configs[config]; }
35
36  inline Weapon* getNextWeapon() { return this->nextWeapon; }
37  inline void setNextWeapon(int config) { if (config == -1) this->nextWeapon = NULL; else this->nextWeapon = configs[config]; }
38
39  inline void setNextToCurrent() {this->currentWeapon = this->nextWeapon; };
40//   inline void setNextWeapon(const std::string& weaponName){this->nextWeapon = Weapon::createWeapon(weaponName); };
41//   inline void setCurrentWeapon(const std::string& weaponName){ this->currentWeapon = Weapon::createWeapon(weaponName); };
42
43  inline void addWeapon(const std::string& weaponName, int config) {this->configs[config] = Weapon::createWeapon(weaponName); }
44  inline void setWeapon(Weapon* weapon, int config) {this->configs[config] = weapon; };
45  inline Weapon* getWeapon(int config) { if (config > WM_MAX_CONFIGS) return NULL; return this->configs[config]; };
46
47  inline void setWeaponConfig(int slot, int side) { this->weaponSlot = slot; this->weaponSide = side; }
48  inline int getWeaponSlot() { return this->weaponSlot; }
49  inline int getWeaponSide() { return this->weaponSide; }
50
51  void removeWeapon(Weapon* weapon);
52
53private:
54
55  int           weaponSlot;
56  int           weaponSide;
57
58  long          capability;             //!< the capabilities of the Slot @see WeaponSlotCapability.
59
60  Weapon*       configs[WM_MAX_CONFIGS];
61
62  Weapon*       currentWeapon;          //!< The current weapon this slot is carrying.
63  Weapon*       nextWeapon;             //!< either NULL or the next weapon that will be set (require currentWeapon to deactivate)
64
65//   int           currentConfig;
66//   int           nextConfig;
67};
68
69
70#endif /* _WEAPON_SLOT_H */
Note: See TracBrowser for help on using the repository browser.