Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 24, 2005, 11:15:00 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: the new WeaponManager is online :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.h

    r4950 r4951  
    2929#include "base_object.h"
    3030
     31#include "vector.h"
    3132
    3233// FORWARD DECLARATION
     34class PNode;
    3335class Weapon;
    3436class Crosshair;
    3537template <class T> class tAnimation;
    3638
    37 #define    WM_MAX_SLOTS            8                   //!< How many slots the WeaponManager has at its max
    38 #define    WM_MAX_CONFIGS          4                   //!< The maximum number of predefined Configurations
    39 #define    WM_MAX_LOADED_WEAPONS   20                  //!< The
    4039
    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
    4245typedef enum
    4346{
    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
    4850
    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
    5156
    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
    8258} WM_SlotCapability;
    8359
    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.
    9461typedef struct
    9562{
    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.
    9965
     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;
    10069
    10170class WeaponManager : public BaseObject {
    10271  public:
    103     WeaponManager(int slotCount);
     72    WeaponManager(unsigned int slotCount);
    10473    WeaponManager(const TiXmlElement* root);
    10574    ~WeaponManager();
     
    10978    void loadWeapons(const TiXmlElement* root);
    11079
    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);
    11283
    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
    11587    void nextWeaponConf();
    11688
    11789    void fire();
     90
    11891    void tick(float dt);
    119     void draw();
     92    void draw() const;
     93
     94    void debug() const;
    12095
    12196  private:
     97    void setSlotCount(unsigned int slotCount);
     98
    12299    int getNextFreeSlot(int configID);
    123100
    124101  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.
    127103
    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.
    131108
    132109    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)
    133115};
Note: See TracChangeset for help on using the changeset viewer.