Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 24, 2015, 10:51:18 PM (10 years ago)
Author:
fvultier
Message:

There is now a HUD that shows the status of the weapon system: all weapons, weapon modes and their munition. Progress bars show the progress of replenishing munition.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/fabienHS15/src/orxonox/weaponsystem/Munition.cc

    r9667 r10688  
    4545        this->magazines_ = 10;
    4646
    47         this->bUseSeparateMagazines_ = false;
    48         this->bStackMunition_ = true;
     47        this->deployment_ = DEPLOYMENT_STACK;
    4948        this->bAllowMunitionRefilling_ = true;
    5049        this->bAllowMultiMunitionRemovementUnderflow_ = true;
    5150
    52         this->reloadTime_ = 0;
     51        this->reloadTime_ = 0.5f;
    5352    }
    5453
     
    6160    Munition::Magazine* Munition::getMagazine(WeaponMode* user) const
    6261    {
    63         if (this->bUseSeparateMagazines_)
     62        if (deployment_ == DEPLOYMENT_SEPARATE)
    6463        {
    6564            // For separated magazines we definitively need a given user
     
    8786        if (magazine)
    8887        {
    89             if (this->bStackMunition_)
     88            if (deployment_ == DEPLOYMENT_STACK)
    9089                // With stacked munition every magazine contributes to the total amount
    9190                return this->maxMunitionPerMagazine_ * this->magazines_ + magazine->munition_;
     
    109108    unsigned int Munition::getNumMagazines() const
    110109    {
    111         if (this->bStackMunition_)
     110        if (deployment_ == DEPLOYMENT_STACK)
    112111        {
    113112            // If we stack munition and the current magazine is still full, it counts too
     
    122121    unsigned int Munition::getMaxMunition() const
    123122    {
    124         if (this->bStackMunition_)
     123        if (deployment_ == DEPLOYMENT_STACK)
    125124            return this->maxMunitionPerMagazine_ * this->maxMagazines_;
    126125        else
     
    135134            unsigned int munition = magazine->munition_;
    136135
    137             // If we stack munition, we con't care about the current magazine - we just need enough munition in total
    138             if (this->bStackMunition_)
     136            // If we stack munition, we don't care about the current magazine - we just need enough munition in total
     137            if (deployment_ == DEPLOYMENT_STACK)
    139138                munition += this->maxMunitionPerMagazine_ * this->magazines_;
    140139
     
    169168            {
    170169                // Not enough munition
    171                 if (this->bStackMunition_)
     170                if (deployment_ == DEPLOYMENT_STACK)
    172171                {
    173172                    // We stack munition, so just take what we can and then load the next magazine
     
    199198    {
    200199        // As long as we have enough magazines (and don't stack munition) we can reload
    201         return (this->magazines_ > 0 && !this->bStackMunition_);
     200        return (this->magazines_ > 0 && !deployment_ == DEPLOYMENT_STACK);
    202201    }
    203202
     
    207206        if (magazine)
    208207        {
    209             if (this->bStackMunition_)
     208            if (deployment_ == DEPLOYMENT_STACK)
    210209                // With stacked munition, we never have to reload
    211210                return false;
     
    231230
    232231        // If we use separate magazines for each user, we definitively need a user given
    233         if (this->bUseSeparateMagazines_ && !user)
     232        if (deployment_ == DEPLOYMENT_SEPARATE && !user)
    234233            return false;
    235234
    236235        // If we don't use separate magazines, set user to 0
    237         if (!this->bUseSeparateMagazines_)
     236        if (!deployment_ == DEPLOYMENT_SEPARATE)
    238237            user = 0;
    239238
     
    260259            return false;
    261260
    262         if (this->bStackMunition_)
     261        if (deployment_ == DEPLOYMENT_STACK)
    263262        {
    264263            // If we stack munition, we can always add munition until we reach the limit
     
    281280            return false;
    282281
    283         if (this->bStackMunition_)
     282        if (deployment_ == DEPLOYMENT_STACK)
    284283        {
    285284            // Stacking munition means, if a magazine gets full, the munition adds to a new magazine
     
    340339        // TODO: 'amount' is not used
    341340
    342         if (this->bStackMunition_)
     341        if (deployment_ == DEPLOYMENT_STACK)
    343342            // If we stack munition, we can always add new magazines because they contribute directly to the munition
    344343            return (this->getNumMunition(0) < this->getMaxMunition());
     
    357356
    358357        // If zero or less magazines are needed, we definitively don't need more magazines (unless we stack munition - then a magazine contributes directly to the munition)
    359         if (needed_magazines <= 0 && !this->bStackMunition_)
     358        if (needed_magazines <= 0 && !deployment_ == DEPLOYMENT_STACK)
    360359            return false;
    361360
     
    369368            // We get more magazines than we need, so just add the needed amount
    370369            this->magazines_ += needed_magazines;
    371             if (this->bStackMunition_)
     370            if (deployment_ == DEPLOYMENT_STACK)
    372371            {
    373372                // We stack munition, so the additional amount contributes directly to the munition of the current magazine
     
    383382    bool Munition::canRemoveMagazines(unsigned int amount) const
    384383    {
    385         if (this->bStackMunition_)
     384        if (deployment_ == DEPLOYMENT_STACK)
    386385        {
    387386            if (this->magazines_ >= amount)
     
    422421            this->magazines_ -= amount;
    423422        }
    424         else if (this->bStackMunition_)
     423        else if (deployment_ == DEPLOYMENT_STACK)
    425424        {
    426425            // We don't have enough magazines, but we're stacking munition, so additionally remove the bullets from the current magazine
     
    437436    {
    438437        // If we use separate magazines, we need a user
    439         if (this->bUseSeparateMagazines_ && !user)
     438        if (deployment_ == DEPLOYMENT_SEPARATE && !user)
    440439            return false;
    441440
    442441        // If we don't use separate magazines, set user to 0
    443         if (!this->bUseSeparateMagazines_)
     442        if (!deployment_ == DEPLOYMENT_SEPARATE)
    444443            user = 0;
    445444
     
    465464        this->bLoaded_ = false;
    466465
    467         if (bUseReloadTime && munition->reloadTime_ > 0 && !munition->bStackMunition_)
     466        if (bUseReloadTime && munition->reloadTime_ > 0 && !munition->deployment_ == DEPLOYMENT_STACK)
    468467        {
    469468            const ExecutorPtr& executor = createExecutor(createFunctor(&Magazine::loaded, this));
Note: See TracChangeset for help on using the changeset viewer.