Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 9, 2015, 5:55:42 PM (9 years ago)
Author:
fvultier
Message:

Munition may and must now be defined for each pawn separately. This way a heavy cruiser may carry more munition than a drone.

File:
1 edited

Legend:

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

    r10688 r10791  
    315315            return it->second;
    316316        }
    317         else if (identifier->getIdentifier()->isA(Class(Munition)))
    318         {
    319             Munition* munition = identifier->fabricate(this->getContext());
    320             this->munitions_[identifier->getIdentifier()] = munition;
    321             return munition;
    322         }
    323317        else
    324318        {
    325             return 0;
     319            return NULL;
     320        }
     321    }
     322
     323    void WeaponSystem::addMunition(Munition* munition)
     324    {
     325        if (munition == NULL)
     326        {
     327            return;
     328        }
     329
     330        SubclassIdentifier<Munition> identifier = munition->getIdentifier();
     331
     332        if (identifier)
     333        {
     334            this->munitions_[identifier] = munition;
     335            updateMunition();
     336        }
     337        else
     338        {
     339            orxout(internal_warning) << "Adding munition failed. identifier == NULL " << endl;
     340        }
     341    }
     342
     343    void WeaponSystem::updateMunition()
     344    {
     345        for (std::vector<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
     346        {
     347            (*it)->updateMunition();
    326348        }
    327349    }
Note: See TracChangeset for help on using the changeset viewer.