Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 18, 2005, 3:37:42 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: reimplemented WeaponManager, made it as simple as possible. not yet all done

File:
1 edited

Legend:

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

    r3862 r3870  
    3030
    3131
     32/**
     33   \brief this initializes the weaponManager for a given nnumber of weapon slots
     34   \param number of weapon slots of the model/ship <= 8 (limitied)
     35*/
    3236WeaponManager::WeaponManager(int nrOfSlots)
    3337{
    3438  this->nrOfSlots = nrOfSlots;
    35   this->nrOfConfigs = 1;
    36 
    37   for(int i = 0; i < W_MAX_CONFS; ++i)
    38     this->configs[i] = NULL;
    39   this->currentConfig = new weaponConfig;
    40   this->configs[0] = this->currentConfig;
    41 }
     39 
     40  this->currConfID = W_CONFIG1;
     41  this->configs[this->currConfID].bUsed = true;
     42}
     43
    4244
    4345WeaponManager::~WeaponManager()
    4446{
    45 
    46 }
    47 
    48 void WeaponManager::addWeapon(Weapon* weapon, slotID slot, configID config)
    49 {
    50   if(this->configs[config] == NULL)
    51     PRINTF(0)("");
    52   //  this->configs[(int)config]->
    53 }
    54 
    55 void WeaponManager::addWeaponConfig(weaponConfig* config)
    56 {}
     47  /* i dont have to delete the weapons itself, because they are
     48     worldentities and therefore in the entities list of the world
     49  */
     50}
     51
     52
     53void WeaponManager::addWeapon(Weapon* weapon, int slotID, int configID)
     54{
     55  if( slotID == W_FREE_SLOT)
     56    {
     57      int freeSlot = this->getNextFreeSlot();
     58      if( freeSlot < 0 || freeSlot >= this->nrOfSlots)
     59        {
     60          PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
     61          return;
     62        }
     63      this->configs[configID].slots[freeSlot] = weapon;
     64      return;
     65    }
     66  this->configs[configID].slots[slotID] = weapon;
     67  PRINTF(3)("Added a new Weapon to the WeaponManager: config %i/ slot %i\n", configID, slotID);
     68}
     69
    5770
    5871void WeaponManager::nextWeaponConf()
    59 {}
     72{
     73  for(; this->currConfID < W_MAX_CONFIGS && !this->configs[this->currConfID].bUsed; this->currConfID+=1)
     74    printf("");
     75}
     76
    6077
    6178void WeaponManager::prevWeaponConf()
     
    6380
    6481
    65 void WeaponManager::selectConfig(configID config)
    66 {
    67   if( this->configs[(int)config] != NULL)
    68     this->currentConfig = this->configs[(int)config];
    69   else
    70     PRINTF(0)("There is no weapon config defined with the number W_CONF%i", (int)config);
    71 }
    72 
     82void WeaponManager::selectConfig(int confID)
     83{
     84  PRINTF(0)("There is no weapon config defined with the number W_CONF%i", confID);
     85}
     86
     87
     88
     89int WeaponManager::getNextFreeSlot()
     90{
     91  for( int i = 0; i < W_MAX_SLOTS; ++i)
     92    {
     93      if( this->configs[this->currConfID].slots[i] == NULL)
     94        return i;
     95    }
     96  return -1;
     97}
    7398
    7499
Note: See TracChangeset for help on using the changeset viewer.