[10437] | 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" |
---|
[10672] | 10 | #include "weapon.h" |
---|
[10676] | 11 | #include "weapon_manager.h" |
---|
[10437] | 12 | |
---|
| 13 | class Weapon; |
---|
| 14 | |
---|
| 15 | //! a class defining a Slot, where a Weapon can be stored inside. |
---|
| 16 | class WeaponSlot : public PNode |
---|
| 17 | { |
---|
| 18 | ObjectListDeclaration(WeaponSlot); |
---|
| 19 | |
---|
| 20 | public: |
---|
| 21 | |
---|
| 22 | WeaponSlot(); |
---|
| 23 | WeaponSlot(const TiXmlElement* root); |
---|
| 24 | virtual ~WeaponSlot(); |
---|
| 25 | |
---|
[10440] | 26 | virtual void loadParams(const TiXmlElement* root); |
---|
[10437] | 27 | |
---|
[10440] | 28 | void setWeaponClass(); |
---|
| 29 | |
---|
[10437] | 30 | long getCapability() { return this->capability; } |
---|
| 31 | void setCapability(long cap) { this->capability = cap; } |
---|
| 32 | |
---|
| 33 | inline Weapon* getCurrentWeapon() { return this->currentWeapon; } |
---|
[10676] | 34 | inline void setCurrentWeapon(int config) { this->currentWeapon = this->configs[config]; } |
---|
[10437] | 35 | |
---|
| 36 | inline Weapon* getNextWeapon() { return this->nextWeapon; } |
---|
[10676] | 37 | inline void setNextWeapon(int config) { if (config == -1) this->nextWeapon = NULL; else this->nextWeapon = configs[config]; } |
---|
[10437] | 38 | |
---|
[10676] | 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); }; |
---|
[10534] | 42 | |
---|
[10676] | 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]; }; |
---|
[10672] | 46 | |
---|
[10534] | 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 | |
---|
[10676] | 51 | void removeWeapon(Weapon* weapon); |
---|
[10534] | 52 | |
---|
[10438] | 53 | private: |
---|
[10437] | 54 | |
---|
[10534] | 55 | int weaponSlot; |
---|
| 56 | int weaponSide; |
---|
| 57 | |
---|
[10437] | 58 | long capability; //!< the capabilities of the Slot @see WeaponSlotCapability. |
---|
| 59 | |
---|
[10676] | 60 | Weapon* configs[WM_MAX_CONFIGS]; |
---|
| 61 | |
---|
[10437] | 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) |
---|
[10676] | 64 | |
---|
| 65 | // int currentConfig; |
---|
| 66 | // int nextConfig; |
---|
[10437] | 67 | }; |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | #endif /* _WEAPON_SLOT_H */ |
---|