Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

xfer

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