Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weapons/weapon_manager.h @ 6055

Last change on this file since 6055 was 6055, checked in by bensch, 18 years ago

orxonox/trunk: first optimisations with InactiveNode
observe this through changing weapons while showing the PNodes with Shell → World togglePNodeVisibility

File size: 4.5 KB
RevLine 
[4826]1/*!
[4954]2 * @file weapon_manager.h
3 * every big WorldEntity has the ability to carry many different Weapons.
4 * for this to be easy there is the WeaponManager, that handels these weapons,
5 * and changes between them.
6 *
7 *
8 *
9 * @TODO 1. WeaponManager should also handle a List of availiableWeapons.
[4826]10 */
11
12#include "base_object.h"
13
[4955]14#include "crosshair.h"
[4959]15#include "weapon.h"
[4826]16
17// FORWARD DECLARATION
[4837]18template <class T> class tAnimation;
[4826]19
[5435]20#define    WM_MAX_SLOTS            10             //!< How many slots the WeaponManager has at its max
[4951]21#define    WM_MAX_CONFIGS          4              //!< The maximum number of predefined Configurations
22#define    WM_MAX_LOADED_WEAPONS   20             //!< The
[4826]23
[4953]24//! This is a special class, that can handle many different Weapons of a ship/man/whatever.
25/**
26 * this class is designed to interactively changeing multiple weapons (or just one),
27 * and to allow the Weapon itself to enable/disable itself.
28 *
29 * How to configure
30 * 1. set the default values.
[4972]31 * 2. define weapons. connect them to the WeaponManager's configurations (have a look at "player.cc", to see how it works)
[4953]32 * 3. go on and run :)....
33 */
[4826]34class WeaponManager : public BaseObject {
[6055]35
36  //! an enumerator defining a Slot, where a Weapon can be stored inside.
37  typedef struct
38  {
39    PNode         position;               //!< the relative Position to the position of the carrying entity. (const PNode* parent; of WeaponManager)
40    long          capability;             //!< the capabilities of the Slot @see WM_SlotCapability.
41
42    Weapon*       currentWeapon;          //!< The current weapon this slot is carrying.
43    Weapon*       nextWeapon;             //!< either NULL or the next weapon that will be set (require currentWeapon to deactivate)
44  } WM_Slot;
45
[4826]46  public:
[4953]47    WeaponManager(PNode* parent);
[4826]48    WeaponManager(const TiXmlElement* root);
49    ~WeaponManager();
50
51    void init();
52    void loadParams(const TiXmlElement* root);
[4834]53    void loadWeapons(const TiXmlElement* root);
[4826]54
[4964]55    void setSlotCount(unsigned int slotCount);
[4951]56    // setting up the WeaponManager with the following functions
57    void setSlotPosition(int slot, const Vector& position);
[4969]58    void setSlotDirection(int slot, const Quaternion& rotation);
[4954]59    /** @param slot the slot to get the relative position from @returns the relative position of the Carrier to the Slot */
60    const Vector& getSlotPosition(int slot) const { return this->currentSlotConfig[slot].position.getRelCoor(); };
61    void setSlotCapability(int slot, long slotCapability);
62    /** @param slot the slot to get the capabilities from @returns the capabilies */
63    long getSlotCapability(int slot) const { return this->currentSlotConfig[slot].capability; };
64
[4953]65    void setParent(PNode* parent);
[4954]66    /** @returns the Parent (carrier) of this WeaponManager */
67    PNode* getParent() const { return this->parent; };
[4834]68
[4951]69    void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
70    void removeWeapon(Weapon* weapon, int configID = -1);
71
[5750]72    // FIXME ::
73//    bool hasFreeSlot(int configID, long capability = WTYPE_ALL) { return ( getNextFreeSlot(configID, capability ) != -1)? true : false; };
[4955]74
[4954]75    void nextWeaponConfig();
[4952]76    void previousWeaponConfig();
77    void changeWeaponConfig(int weaponConfig);
[4826]78
[4955]79    /** @returns a fixed target namely the Crosshair's 3D position */
[5750]80    inline PNode* getFixedTarget() const { return this->crosshair; };
81
[4826]82    void fire();
[5750]83    //! @TODO: implement this function (maybe also in Weapon itself)
84    void releaseFire();
[4951]85
[4833]86    void tick(float dt);
[4951]87    void draw() const;
[4826]88
[4951]89    void debug() const;
90
[5750]91 // private:
[5440]92    int getNextFreeSlot(int configID, long capability = WTYPE_ALL);
[4834]93
[4837]94  private:
[4954]95    PNode*                  parent;                                   //!< The parent, this WeaponManager is connected to.
[4826]96
[4954]97    int                     slotCount;                                //!< number of weapon slots the ship has.
98    int                     currentConfigID;                          //!< the currently selected config.
99    Weapon*                 configs[WM_MAX_CONFIGS][WM_MAX_SLOTS];    //!< An array of predefined configurations and assigned weapon.
100    WM_Slot                 currentSlotConfig[WM_MAX_SLOTS];          //!< The currentConfigureation.
[4949]101
[4954]102    Weapon*                 availiableWeapons[WM_MAX_LOADED_WEAPONS]; //!< The availiable Weapons of this WeaponManager
[4951]103
104    bool                    weaponChange;
105
[4954]106    Crosshair*              crosshair;                                //!< an aim.
107    tAnimation<Crosshair>*  crossHairSizeAnim;                        //!< An animation for the crosshair (scaling)
[4826]108};
Note: See TracBrowser for help on using the repository browser.