Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 26, 2008, 7:48:26 PM (16 years ago)
Author:
dsommer
Message:

Added ShipEquipment to Pawn and various funtions for it -not compiling, because private…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickups2/src/orxonox/objects/pickup/Item.cc

    r2227 r2289  
    2929void Item::addTo (Pawn* player)
    3030{
    31         //player->Equipment.insert ( std::pair<std::string, Item*>(this->itemname,this) );
     31        if(checkSlot(player)==true)
     32        player->pickUp.Equipment.insert ( std::pair<std::string, Item*>(this->getName(),this) );
     33        else
     34        COUT(3) << "swap?" << std::endl;
    3235}
    33 
     36bool Item::remove(Pawn* player)
     37{
     38        if(player->pickUp.Equipment.find(this->getName())!= player->pickUp.Equipment.end())
     39        {
     40        std::multimap<std::string,Item*>::iterator it;
     41        it=player->pickUp.Equipment.find(this->getName());
     42        player->pickUp.Equipment.erase (it);
     43        return true;
     44        }
     45        else
     46        return false;
     47}
     48bool Item::checkSlot(Pawn* player)
     49{
     50        std::multimap<std::string,Item*>::iterator it;
     51        for ( it=player->pickUp.Equipment.begin() ; it != player->pickUp.Equipment.end(); it++ )
     52        {
     53        if((*it).second->playerBaseClass_==this->playerBaseClass_)
     54        return false;
     55        }
     56        return true;
     57}
    3458void Item::setPlayerBaseClassName(const std::string& name)
    3559{
Note: See TracChangeset for help on using the changeset viewer.