Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 1, 2008, 11:17:22 PM (16 years ago)
Author:
landauf
Message:
  • added a WeaponSystem to Pawn
  • initialized values in weapon classes and fixed some vector limit conditions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/WeaponSystem.cc

    r2097 r2098  
    4848    {
    4949        RegisterObject(WeaponSystem);
     50
     51        this->activeWeaponSet_ = 0;
     52        this->parentSpaceShip_ = 0;
    5053    }
    5154
     
    6265
    6366    //the first weaponSet is at n=0
    64     void WeaponSystem::setActiveWeaponSet(int n)
     67    void WeaponSystem::setActiveWeaponSet(unsigned int n)
    6568    {
    66         if ( (int) weaponSets_.size() <= n )
    67             n=0;
    68         this->activeWeaponSet_ = this->weaponSets_[n];
     69        if (n < this->weaponSets_.size())
     70            this->activeWeaponSet_ = this->weaponSets_[n];
    6971    }
    7072
    7173    //n is the n'th weaponSet, starting with zero
    7274    //Spaceship.cc only needs to have the keybinding to a specific Set-number n
    73     void WeaponSystem::fire(int n)
     75    void WeaponSystem::fire(unsigned int n)
    7476    {
    75         if (n>=0)
     77        if (n < this->weaponSets_.size())
    7678            this->weaponSets_[n]->fire();
    7779    }
    7880
    79     WeaponSet * WeaponSystem::getWeaponSetPointer(int n)
     81    void WeaponSystem::fire()
    8082    {
    81         return this->weaponSets_[n];
     83        if (this->activeWeaponSet_)
     84            this->activeWeaponSet_->fire();
     85    }
     86
     87    WeaponSet * WeaponSystem::getWeaponSetPointer(unsigned int n)
     88    {
     89        if (n < this->weaponSets_.size())
     90            return this->weaponSets_[n];
     91        else
     92            return 0;
    8293    }
    8394
Note: See TracChangeset for help on using the changeset viewer.