Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/weapons/weapon.h @ 4837

Last change on this file since 4837 was 4836, checked in by bensch, 19 years ago

orxonox/trunk: renamed all the \param → @param and so on in Doxygen tags.
Thanks a lot to the kDevelop team. this took since the last commit :)

File size: 4.8 KB
Line 
1/*!
2    \file weapon.h
3  *  a weapon that a  can use
4
5
6    A weapon is characterized by:
7     o firing-rate: the initial firing rate of a weapon (1/s = Herz)
8     o slowdown-factor: this is a factor d: exp(-d*x), d is element of all positive R. it determines how fast the firing-rate will slow down. if no slowdown: d=0, the bigger d is, the faster the weapon will slow down!
9     o energy-consumption: this determines the energy that has to be used to produce this projectile = costs per projectile
10
11    Furthermore there are some other attributes, that will help to represent a firing
12    weapon in this world:
13     o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented
14     o shooting animation
15*/
16
17
18#ifndef _WEAPON_H
19#define _WEAPON_H
20
21#include "base_object.h"
22#include "world_entity.h"
23
24// FORWARD DECLARATION
25class Projectile;
26class Weapon;
27class Animation3D;
28class TiXmlElement;
29
30//! An enumerator defining actions a Weapon can take
31typedef enum {
32  WA_NONE          =    0,    //!< No Action taken
33  WA_SHOOT         =    1,    //!< emitting Shot
34  WA_CHARGE        =    2,    //!< charge action (one click before the shot)
35  WA_RELOAD        =    3,    //!< reload right after shoot is finished
36  WA_ACTIVATE      =    4,    //!< activate the GUN
37  WA_DEACTIVATE    =    5,    //!< deactivate the GUN
38  WA_SPECIAL1      =    6,    //!< Special Action taken
39
40  WA_ACTION_COUNT  =    7     //!< This must match the count of enumerations-members.
41} WeaponActions;
42
43//! An enumerator defining the States of a Weapon
44typedef enum {
45  WS_NONE          =    0,    //!< No State at all (if set, there is something wrong, or the weapon is not yet availiable)
46  WS_SHOOTING      =    1,    //!< The State of the Shooting
47  WS_RELOADING     =    3,    //!< The State of the Reloading
48  WS_ACTIVATING    =    4,    //!< The State in which the weapon gets activated
49  WS_DEACTIVATING  =    5,    //!< The State in which the weapon gets deactivated
50  WS_INACTIVE      =    6,    //!< The State where the weapon is inactive (unable to shoot)
51  WS_IDLE          =    7,    //!< The State where the weapon is idle
52
53  WS_STATE_COUNT  =     8      //!< This must match the count of the enumerations-members.
54} WeaponState;
55
56
57//! a weapon can be left or right sided
58/**
59 * @todo this will be reset with mirror X/Y/Z
60 */
61#define    W_LEFT        0
62#define    W_RIGHT       1
63
64//! An abstract class, that describes weapons
65/**
66 * This is used as a container for all the different kinds of weapons that may exist
67 */
68class Weapon : public WorldEntity
69{
70  friend class World;
71
72 public:
73  Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction);
74  Weapon(const TiXmlElement* root);
75  virtual ~Weapon ();
76
77  void init();
78  void loadParams(const TiXmlElement* root);
79
80  void enable();
81  void disable();
82  bool isEnabled();
83
84  void setProjectile(Projectile* projectile);
85  Projectile* getProjectile();
86
87  virtual void activate();
88  virtual void deactivate();
89  bool isActive();
90
91
92  /** @param idle time in ms  */
93  inline void setWeaponIdleTime(float idleTime) { this->idleTime = idleTime; };
94  /** @returns idle time in ms */
95  inline float getWeaponIdleTime() const { return this->idleTime; };
96  /** @return true if idletime is elapsed else otherwise */
97  inline bool hasWeaponIdleTimeElapsed() const { return (this->localTime>this->idleTime)?true:false; };
98
99  /**  fires the weapon */
100  virtual void fire() = 0;
101  virtual void hit (WorldEntity* weapon, const Vector& loc);
102  virtual void destroy();
103
104  virtual void tick(float time);
105  virtual void weaponIdle();
106  virtual void draw();
107
108 protected:
109
110  float                localTime;                        //<! this is the local time. important for shooting attributes like frequency
111  float                idleTime;                         //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay
112  float                slowDownFactor;                   //<! if the shooting frequency is a linear function of time...
113
114  ////////////
115  // PHASES //
116  ////////////
117  float                times[WS_STATE_COUNT];            //!< Times to stay in the different States @see WeaponState
118  SoundBuffer*         soundBuffers[WA_ACTION_COUNT];    //!< SoundBuffers for all actions @see WeaponAction
119  Animation3D*         animation[WS_STATE_COUNT];        //!< Animations for all the States (you can say yourself on what part of the gun this animation acts).
120
121
122  SoundBuffer*         fireSound;
123  SoundSource*         weaponSource;
124
125
126 private:
127   WeaponState          state;                           //!< The state this weapon is in.
128   bool                 enabled;                         //<! states if the weapon is enabled or not
129   Projectile*          projectile;                      //<! the projectile used for this weapon
130  //WeaponSound sound;
131};
132
133#endif /* _WEAPON_H */
Note: See TracBrowser for help on using the repository browser.