Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 9, 2005, 12:48:50 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: state is no more singleton, but static class.
This is faster, and easier to handle, because one can just say State::getBLA() and not State::getInstance()→getBLA(); ——→>> less redundant

File:
1 edited

Legend:

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

    r4826 r4827  
    11/*!
    22    \file weapon.h
    3     \brief a weapon that a player can use
     3    \brief a weapon that a can use
    44
    55
     
    4242// } WeaponSoundType;
    4343
     44
     45//! An enumerator defining the States of a Weapon
    4446typedef enum {
    45   W_NONE,
    46   W_SHOOT,
    47   W_RELOAD,
    48   W_ACTIVATING,
    49   W_DEACTIVATE,
    50   W_IDLE,
     47  W_NONE          =    0,    //!< No State at all (if set, there is something wrong, or the weapon is not yet availiable)
     48  W_SHOOT         =    1,    //!< The State of the Shooting
     49  W_RELOAD        =    2,    //!< The State of the Reloading
     50  W_ACTIVATING    =    3,    //!< The State in which the weapon gets activated
     51  W_DEACTIVATING  =    4,    //!< The State in which the weapon gets deactivated
     52  W_INACTIVE      =    5,    //!< The State where the weapon is inactive (unable to shoot)
     53  W_IDLE          =    6,    //!< The State where the weapon is idle
     54
     55  W_STATES_COUNT  =    6     //!< This must match the count of the enumerations (without W_NONE)
    5156} WeaponState;
    5257
     
    5661#define    W_RIGHT       1
    5762
    58 
    59 
    60 
    61 
     63//! An abstract class, that describes weapons
     64/**
     65 * This is used as a container for all the different kinds of weapons that may exist
     66 * Animations/Sounds/etc. will be handled in the Extensions of this class.
     67 */
    6268class Weapon : public WorldEntity
    6369{
     
    8490
    8591
    86   /**
    87      \brief sets a weapons idle time
    88      \param idle time in ms
     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; };
    8998
    90      a weapon idle time is the time spend after a shoot until the weapon can
    91      shoot again
    92   */
    93   inline void setWeaponIdleTime(float time) { this->idleTime = time; }
    94   /**
    95      \brief gets the weapon idle time
    96      \returns idle time in ms
    97    */
    98   inline float getWeaponIdleTime() const { return this->idleTime;}
    99   /**
    100      \brief checks if the idle time is elapsed
    101      \return true if time is elapsed
    102 
    103      a weapon idle time is the time spend after a shoot until the weapon can
    104    shoot again
    105   */
    106   inline bool hasWeaponIdleTimeElapsed() const { return (this->localTime>this->idleTime)?true:false; }
    107 
    108   /**
    109      \brief fires the weapon
    110 
    111      this is called from the player.cc, when fire-button is been pushed
    112   */
     99  /** @brief fires the weapon */
    113100  virtual void fire() = 0;
    114101  virtual void hit (WorldEntity* weapon, Vector* loc);
     
    120107
    121108 protected:
    122   tList<WorldEntity>* worldEntities;
    123   float localTime;                 //<! this is the local time. important for shooting attributes like frequency
    124   float idleTime;                  //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay
    125   float slowDownFactor;            //<! if the shooting frequency is a linear function of time...
     109  tList<WorldEntity>*  worldEntities;
    126110
    127   PNode* objectComponent1;         //<! the gun is made of multiple parts, these PNodes represent their location and orientation
    128   PNode* objectComponent2;
    129   PNode* objectComponent3;
     111  float                localTime;                 //<! this is the local time. important for shooting attributes like frequency
     112  float                idleTime;                  //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay
     113  float                slowDownFactor;            //<! if the shooting frequency is a linear function of time...
    130114
    131   Animation3D* animation1;
    132   Animation3D* animation2;
    133   Animation3D* animation3;
    134 
    135   Vector projectileOffset;
    136   int leftRight;   // this will become an enum
    137 
    138   SoundBuffer* fireSound;
    139   SoundSource* weaponSource;
     115  SoundBuffer*         fireSound;
     116  SoundSource*         weaponSource;
    140117
    141118
    142119 private:
    143   bool enabled;                    //<! states if the weapon is enabled or not
    144   Projectile* projectile;          //<! the projectile used for this weapon
     120  bool                 enabled;                    //<! states if the weapon is enabled or not
     121  Projectile*          projectile;          //<! the projectile used for this weapon
    145122  //WeaponSound sound;
    146123};
Note: See TracChangeset for help on using the changeset viewer.