Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5498 in orxonox.OLD for trunk/src/world_entities/weapons/weapon.cc


Ignore:
Timestamp:
Nov 7, 2005, 10:43:22 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: redocumented the WorldEntity and Weapon classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/weapon.cc

    r5441 r5498  
    6565/**
    6666 * initializes the Weapon with ALL default values
     67 *
     68 * This Sets the default values of the Weapon
    6769 */
    6870void Weapon::init()
    6971{
    70   this->currentState     = WS_INACTIVE;
    71   this->requestedAction  = WA_NONE;
    72   this->stateDuration    = 0.0;
    73   for (int i = 0; i < WS_STATE_COUNT; i++)
     72  this->currentState     = WS_INACTIVE;            //< Normaly the Weapon is Inactive
     73  this->requestedAction  = WA_NONE;                //< No action is requested by default
     74  this->stateDuration    = 0.0;                    //< All the States have zero duration
     75  for (int i = 0; i < WS_STATE_COUNT; i++)         //< Every State has:
    7476    {
    75       this->times[i] = 0.0;
    76       this->animation[i] = NULL;
     77      this->times[i] = 0.0;                        //< An infinitesimal duration
     78      this->animation[i] = NULL;                   //< No animation
    7779    }
    7880  for (int i = 0; i < WA_ACTION_COUNT; i++)
    79     this->soundBuffers[i] = NULL;
    80 
    81   this->soundSource = new SoundSource(this);
    82   this->emissionPoint.setParent(this);
    83 
    84   this->projectile = CL_NULL;
    85   this->projectileFactory = NULL;
    86 
    87   this->hideInactive = true;
    88 
    89   this->minCharge = 1.0;
    90   this->maxCharge = 1.0;
    91 
    92   this->energyLoaded = .0;
    93   this->energyLoadedMax = 5.0;
    94   this->energy = .0;
    95   this->energyMax = 10.0;
    96   this->capability = WTYPE_ALL;
    97 
    98   this->setWeaponManager(NULL);
    99 }
    100 
     81    this->soundBuffers[i] = NULL;                  //< No Sounds
     82
     83  this->soundSource = new SoundSource(this);       //< Every Weapon has exacty one SoundSource.
     84  this->emissionPoint.setParent(this);             //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles
     85
     86  this->projectile = CL_NULL;                      //< No Projectile Class is Connected to this weapon
     87  this->projectileFactory = NULL;                  //< No Factory generating Projectiles is selected.
     88
     89  this->hideInactive = true;                       //< The Weapon will be hidden if it is inactive (by default)
     90
     91  this->minCharge = 1.0;                           //< The minimum charge the Weapon can hold is 1 unit.
     92  this->maxCharge = 1.0;                           //< The maximum charge is also one unit.
     93
     94  this->energyLoaded = .0;                         //< How much energy is loaded in the Gun. (Weapons must be charged befor usage)
     95  this->energyLoadedMax = 5.0;                     //< Each Weapon has a Maximum energy that can be charged onto it
     96  this->energy = .0;                               //< The secondary Buffer (before we have to reload)
     97  this->energyMax = 10.0;                          //< How much energy can be carried
     98  this->capability = WTYPE_ALL;                    //< The Weapon has all capabilities @see W_Capability.
     99
     100  this->setWeaponManager(NULL);                    //< By default the Weapon is free, and unhandled by a WeaponManager (this is good for small enemies).
     101}
     102
     103/**
     104 * loads the Parameters of a Weapon
     105 * @param root the XML-Element to load the Weapons settings from
     106 */
    101107void Weapon::loadParams(const TiXmlElement* root)
    102108{
     
    121127 * @returns true, if it was sucessfull, false on error
    122128 *
    123  * be aware, that this function does not create Factories, as this is job of Bullet-classes.
     129 * be aware, that this function does not create Factories, as this is job of Projecitle/Bullet-classes.
     130 * What it does, is telling the Weapon what Projectiles it can Emit.
    124131 */
    125132void Weapon::setProjectileType(ClassID projectile)
     
    166173/**
    167174 * prepares Projectiles of the Weapon
    168  * @param count how many Projectiles to create
     175 * @param count how many Projectiles to create (they will be stored in the ProjectileFactory)
    169176 */
    170177void Weapon::prepareProjectiles(unsigned int count)
     
    178185/**
    179186 * resurects and returns a Projectile
    180  * @returns a Projectile on success, NULL on error (ProjectileFastFactory not Found)
     187 * @returns a Projectile on success, NULL on error
     188 *
     189 * errors: 1. (ProjectileFastFactory not Found)
     190 *         2. No more Projectiles availiable.
    181191 */
    182192Projectile* Weapon::getProjectile()
     
    186196  else
    187197  {
    188     PRINTF(2)("No projectile defined for Weapon %s(%s) cant return any\n", this->getName(), this->getClassName());
     198    PRINTF(2)("No projectile defined for Weapon %s(%s) can't return any\n", this->getName(), this->getClassName());
    189199    return NULL;
    190200  }
     
    307317}
    308318
    309 //////////////////////
    310 // WEAPON INTERNALS //
    311 //////////////////////
     319////////////////////////////////////////////////////////////
     320// WEAPON INTERNALS                                       //
     321// These are functions, that no other Weapon should over- //
     322// write. No class has direct Access to them, as it is    //
     323// quite a complicated process, handling a Weapon from    //
     324// the outside                                            //
     325////////////////////////////////////////////////////////////
    312326/**
    313327 * executes an action, and with it starts a new State.
     
    531545/**
    532546 * checks wether all the Weapons functions are valid, and if it is possible to go to action with it.
    533  *
     547 * @todo IMPLEMENT the Weapons Check
    534548 */
    535549bool Weapon::check() const
     
    561575}
    562576
    563 
    564 // static
     577////////////////////////////////////////////////////////
     578// static Definitions (transormators for readability) //
     579////////////////////////////////////////////////////////
    565580/**
    566581 * Converts a String into an Action.
Note: See TracChangeset for help on using the changeset viewer.