Changeset 4951 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons/weapon_manager.h
- Timestamp:
- Jul 24, 2005, 11:15:00 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapons/weapon_manager.h
r4950 r4951 29 29 #include "base_object.h" 30 30 31 #include "vector.h" 31 32 32 33 // FORWARD DECLARATION 34 class PNode; 33 35 class Weapon; 34 36 class Crosshair; 35 37 template <class T> class tAnimation; 36 38 37 #define WM_MAX_SLOTS 8 //!< How many slots the WeaponManager has at its max38 #define WM_MAX_CONFIGS 4 //!< The maximum number of predefined Configurations39 #define WM_MAX_LOADED_WEAPONS 20 //!< The40 39 41 //! this is an identifier for the weapon config 40 #define WM_MAX_SLOTS 8 //!< How many slots the WeaponManager has at its max 41 #define WM_MAX_CONFIGS 4 //!< The maximum number of predefined Configurations 42 #define WM_MAX_LOADED_WEAPONS 20 //!< The 43 44 //! an enumerator defining capabilities of a WeaponSlot 42 45 typedef enum 43 46 { 44 WM_CONFIG0 = 0, 45 WM_CONFIG1 = 1, 46 WM_CONFIG2 = 2, 47 WM_CONFIG3 = 3, 47 WM_SLOTC_DIRECTIONAL = 0x00000001, //!< if the Slot is able to carry directional weapons 48 WM_SLOTC_TURRET = 0x00000002, //!< if the Slot is able to carry turrets 49 WM_SLOTC_ALLKINDS = 0x0000000f, //!< if the Slot is able to carry all kinds of weapons 48 50 49 WM_CONFIGCOUNT = 4 50 } WM_CONFIG; 51 WM_SLOTC_FORWARD = 0x00000010, //!< if the Slot is able to carry weapons firing forward 52 WM_SLOTC_BACKWARD = 0x00000020, //!< if the Slot is able to carry weapons firing backwards 53 WM_SLOTC_LEFT = 0x00000040, //!< if the Slot is able to carry weapons firing to the left 54 WM_SLOTC_RIGHT = 0x00000080, //!< if the Slot is able to carry weapons firing to the right 55 WM_SLOTC_ALLDIRS = 0x000000f0, //!< this slot can fire into all directions 51 56 52 //! this is an identifier for the slot. there are up to 8 weapon slots -> this means there can't be more than 8 weapons at the same time 53 typedef enum 54 { 55 WM_SLOT0 = 0, 56 WM_SLOT1 = 1, 57 WM_SLOT2 = 2, 58 WM_SLOT3 = 3, 59 WM_SLOT4 = 4, 60 WM_SLOT5 = 5, 61 WM_SLOT6 = 6, 62 WM_SLOT7 = 7, 63 64 WM_SLOT_COUNT = 8, 65 66 WM_FREE_SLOT = -1 67 } WM_SLOT; 68 69 typedef enum 70 { 71 WM_SLOTC_DIRECTIONAL = 1, 72 WM_SLOTC_TURRET = 2, 73 WM_SLOTC_ALLKINDS = 3, 74 75 WM_SLOTC_FORWARD = 4, 76 WM_SLOTC_BACKWARD = 8, 77 WM_SLOTC_LEFT = 16, 78 WM_SLOTC_RIGHT = 32, 79 WM_SLOTC_ALLDIRS = 60, 80 81 WM_SLOTC_ALL = 63, 57 WM_SLOTC_ALL = 0x000000ff, //!< everything allowed in this slot 82 58 } WM_SlotCapability; 83 59 84 typedef struct WM_Slot 85 { 86 int number; 87 long capability; 88 89 Weapon* currentWeapon; 90 Weapon* nextWeapon; 91 }; 92 93 //! this is a weapon Configuration: it has up to 8 slots 60 //! an enumerator defining a Slot, where a Weapon can be stored inside. 94 61 typedef struct 95 62 { 96 bool bUsed; //!< is set to true, if this configuration is 97 Weapon* slots[WM_MAX_SLOTS]; 98 } weaponConfig; 63 Vector position; //!< the relative Position to the position of the carrying entity. (const PNode* parent; of WeaponManager) 64 long capability; //!< the capabilities of the Slot @see WM_SlotCapability. 99 65 66 Weapon* currentWeapon; //!< The current weapon this slot is carrying. 67 Weapon* nextWeapon; //!< either NULL or the next weapon that will be set (require currentWeapon to deactivate) 68 } WM_Slot; 100 69 101 70 class WeaponManager : public BaseObject { 102 71 public: 103 WeaponManager( int slotCount);72 WeaponManager(unsigned int slotCount); 104 73 WeaponManager(const TiXmlElement* root); 105 74 ~WeaponManager(); … … 109 78 void loadWeapons(const TiXmlElement* root); 110 79 111 void setSlotCount(int slotCount); 80 // setting up the WeaponManager with the following functions 81 void setSlotPosition(int slot, const Vector& position); 82 void setSlotCapability(long slotCapability); 112 83 113 void addWeapon(Weapon* weapon, int configID = WM_CONFIG0, int slotID = WM_FREE_SLOT); 114 void removeWeapon(Weapon* weapon, int configID = WM_CONFIG0); 84 void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1); 85 void removeWeapon(Weapon* weapon, int configID = -1); 86 115 87 void nextWeaponConf(); 116 88 117 89 void fire(); 90 118 91 void tick(float dt); 119 void draw(); 92 void draw() const; 93 94 void debug() const; 120 95 121 96 private: 97 void setSlotCount(unsigned int slotCount); 98 122 99 int getNextFreeSlot(int configID); 123 100 124 101 private: 125 Crosshair* crosshair; //!< an aim. 126 tAnimation<Crosshair>* crossHairSizeAnim; //!< An animation for the crosshair (scaling) 102 PNode* parent; //!< The parent, this WeaponManager is connected to. 127 103 128 int slotCount; //!< number of weapon slots a ship has 129 int currConfID; //!< the currently selected config 130 weaponConfig configs[4]; //!< a list of four configurations 104 int slotCount; //!< number of weapon slots the ship has. 105 int currentConfigID; //!< the currently selected config. 106 Weapon* configs[WM_MAX_CONFIGS][WM_MAX_SLOTS]; //!< An array of predefined configurations and assigned weapon. 107 WM_Slot currentSlotConfig[WM_MAX_SLOTS]; //!< The currentConfigureation. 131 108 132 109 Weapon* availiableWeapons[WM_MAX_LOADED_WEAPONS]; 110 111 bool weaponChange; 112 113 Crosshair* crosshair; //!< an aim. 114 tAnimation<Crosshair>* crossHairSizeAnim; //!< An animation for the crosshair (scaling) 133 115 };
Note: See TracChangeset
for help on using the changeset viewer.