Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 11, 2005, 12:55:48 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: setClassID implemented in all files

File:
1 edited

Legend:

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

    r4000 r4597  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    1313   ### File Specific
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: 
     15   co-programmer:
    1616*/
    1717
     
    3535   \param number of weapon slots of the model/ship <= 8 (limitied)
    3636*/
    37 WeaponManager::WeaponManager(int nrOfSlots)
    38 {
     37WeaponManager::WeaponManager(int nrOfSlots)
     38{
     39  this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
     40
    3941  for(int i = 0; i < W_MAX_CONFIGS; ++i)
    4042    {
    4143      this->configs[i].bUsed = false;
    4244      for(int j = 0; j < W_MAX_SLOTS; ++j)
    43         this->configs[i].slots[j] = NULL;
     45        this->configs[i].slots[j] = NULL;
    4446    }
    4547  this->nrOfSlots = nrOfSlots;
     
    4850
    4951
    50 WeaponManager::~WeaponManager() 
    51 {
    52   /* 
    53      i dont have to delete the weapons itself, because they are 
     52WeaponManager::~WeaponManager()
     53{
     54  /*
     55     i dont have to delete the weapons itself, because they are
    5456     worldentities and therefore in the entities list of the world.
    5557     world will clean them up for me
     
    5961      this->configs[i].bUsed = false;
    6062      for(int j = 0; j < W_MAX_SLOTS; ++j)
    61         this->configs[i].slots[j] = NULL;
     63        this->configs[i].slots[j] = NULL;
    6264    }
    6365}
     
    7274   if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be
    7375   replaced by the weapon specified. if you use the W_FREE_SLOT, the manager will look for a free
    74    slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 
     76   slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be
    7577   a error message.
    7678*/
    77 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 
     79void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID)
    7880{
    7981  if( slotID == W_FREE_SLOT)
     
    8183      int freeSlot = this->getNextFreeSlot( configID);
    8284      if( freeSlot < 0 || freeSlot >= this->nrOfSlots)
    83         {
    84           PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
    85           return;
    86         }
     85        {
     86          PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
     87          return;
     88        }
    8789      PRINTF(3)("Added new Weapon to Config:%i/Slot:%i\n", configID, freeSlot);
    8890      this->configs[configID].bUsed = true;
     
    108110   this function will deactivate the weapons first, change the config and reactivate them later
    109111*/
    110 void WeaponManager::nextWeaponConf() 
     112void WeaponManager::nextWeaponConf()
    111113{
    112114  PRINTF(4)("Changing weapon configuration: from %i to next\n", this->currConfID);
     
    116118  for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i);
    117119  if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0;
    118   else this->currConfID = i; 
    119 
    120  
     120  else this->currConfID = i;
     121
     122
    121123  Weapon *w1, *w2;
    122124  for(int j = 0; j < W_MAX_SLOTS; ++j)
     
    124126      w1 = this->configs[lastConfID].slots[j];
    125127      w2 = this->configs[this->currConfID].slots[j];
    126      
     128
    127129      if( w1 == w2)
    128         {
    129           printf("no need for change\n");
    130         }
     130        {
     131          printf("no need for change\n");
     132        }
    131133      else
    132         {
    133         if( w1 != NULL )
    134           {
    135             w1->deactivate();
    136             printf("deactivating %i,%i\n", j,lastConfID);
    137           }
    138         if( w2 != NULL)
    139           {
    140             w2->activate();
    141             printf("activating %i,%i\n", j, this->currConfID);
    142           }
    143         }
     134        {
     135        if( w1 != NULL )
     136          {
     137            w1->deactivate();
     138            printf("deactivating %i,%i\n", j,lastConfID);
     139          }
     140        if( w2 != NULL)
     141          {
     142            w2->activate();
     143            printf("activating %i,%i\n", j, this->currConfID);
     144          }
     145        }
    144146    }
    145147}
     
    199201    {
    200202      if( this->configs[configID].slots[i] == NULL)
    201         return i;
     203        return i;
    202204    }
    203205  return -1;
     
    214216   creates a new weapon
    215217*/
    216 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 
     218Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction)
    217219  : WorldEntity()
    218220{
     
    236238   \brief standard deconstructor
    237239*/
    238 Weapon::~Weapon () 
     240Weapon::~Weapon ()
    239241{
    240242  // model will be deleted from WorldEntity-destructor
    241243  //this->worldEntities = NULL;
    242  
     244
    243245  /* dont delete objectComponentsX here, they will be killed when the pnodes are cleaned out */
    244246
     
    247249
    248250
    249 /** 
     251/**
    250252    \brief enables the weapon
    251253
    252     a weapon can be enabled/disabled because of various reasons. if a weapon is 
     254    a weapon can be enabled/disabled because of various reasons. if a weapon is
    253255    been enabled, it can interact in a world. elswhere it wont react to any
    254256    action.
     
    260262
    261263
    262 /** 
     264/**
    263265    \brief disables the weapon
    264266
    265     a weapon can be enabled/disabled because of various reasons. if a weapon is 
     267    a weapon can be enabled/disabled because of various reasons. if a weapon is
    266268    been enabled, it can interact in a world. elswhere it wont react to any
    267269    action.
     
    273275
    274276
    275 /** 
     277/**
    276278    \brief checks if the weapon is enabled
    277279    \returns true if enabled
    278280
    279     a weapon can be ebabled/disabled because of various reasons. if a weapon is 
     281    a weapon can be ebabled/disabled because of various reasons. if a weapon is
    280282    been enabled, it can interact in a world. elswhere it wont react to any
    281283    action.
     
    314316   \brief this activates the weapon
    315317
    316    This is needed, since there can be more than one weapon on a ship. the 
    317    activation can be connected with an animation. for example the weapon is 
    318    been armed out. 
     318   This is needed, since there can be more than one weapon on a ship. the
     319   activation can be connected with an animation. for example the weapon is
     320   been armed out.
    319321*/
    320322void Weapon::activate()
     
    325327   \brief this deactivates the weapon
    326328
    327    This is needed, since there can be more than one weapon on a ship. the 
    328    activation can be connected with an animation. for example the weapon is 
     329   This is needed, since there can be more than one weapon on a ship. the
     330   activation can be connected with an animation. for example the weapon is
    329331   been armed out.
    330332*/
     
    352354   can destroy the weapons of enemies or vice versa.
    353355*/
    354 void Weapon::hit (WorldEntity* entity, Vector* position) 
     356void Weapon::hit (WorldEntity* entity, Vector* position)
    355357{}
    356358
     
    362364   hit, it can also be destoryed.
    363365*/
    364 void Weapon::destroy () 
     366void Weapon::destroy ()
    365367{}
    366368
     
    369371   \brief tick signal for time dependent/driven stuff
    370372*/
    371 void Weapon::tick (float time) 
     373void Weapon::tick (float time)
    372374{}
    373375
     
    383385   \brief this will draw the weapon
    384386*/
    385 void Weapon::draw () 
    386 {}
    387 
     387void Weapon::draw ()
     388{}
     389
Note: See TracChangeset for help on using the changeset viewer.