| [2500] | 1 | /* has to be added to player | 
|---|
 | 2 |    multimap<std::string, BaseItem*> Equipment;*/ | 
|---|
 | 3 |  | 
|---|
 | 4 |  | 
|---|
| [2503] | 5 | #include "OrxonoxStableHeaders.h" | 
|---|
| [2500] | 6 | #include "BaseItem.h" | 
|---|
 | 7 | #include "core/CoreIncludes.h" | 
|---|
 | 8 | #include "core/XMLPort.h" | 
|---|
 | 9 | #include "util/String.h" | 
|---|
 | 10 | #include "objects/worldentities/pawns/Pawn.h" | 
|---|
 | 11 |  | 
|---|
 | 12 |  | 
|---|
 | 13 | namespace orxonox | 
|---|
 | 14 | { | 
|---|
 | 15 | BaseItem::BaseItem(BaseObject* creator) : BaseObject(creator) | 
|---|
 | 16 | { | 
|---|
 | 17 |         RegisterObject(BaseItem); | 
|---|
 | 18 |  | 
|---|
 | 19 |         this->playerBaseClass_ = 0; | 
|---|
 | 20 | } | 
|---|
 | 21 |  | 
|---|
 | 22 | BaseItem::~BaseItem() | 
|---|
 | 23 | { | 
|---|
 | 24 | } | 
|---|
 | 25 |     void BaseItem::XMLPort(Element& xmlelement, XMLPort::Mode mode) | 
|---|
 | 26 |     { | 
|---|
 | 27 |         SUPER(BaseItem, XMLPort, xmlelement, mode); | 
|---|
 | 28 |  | 
|---|
 | 29 |         XMLPortParam(BaseItem, "playerclass", setPlayerBaseClassName, getPlayerBaseClassName, xmlelement, mode); | 
|---|
 | 30 |     } | 
|---|
 | 31 |  | 
|---|
 | 32 | bool BaseItem::addTo (Pawn* player) | 
|---|
 | 33 | { | 
|---|
 | 34 |  | 
|---|
 | 35 |         return player->getPickUp().insert(this); | 
|---|
 | 36 |         /*if(checkSlot(player)==true) | 
|---|
 | 37 |         player->pickUp.Equipment.insert ( std::pair<std::string, BaseItem*>(this->getName(),this) ); | 
|---|
 | 38 |         else | 
|---|
 | 39 |         COUT(3) << "swap?" << std::endl;*/ | 
|---|
 | 40 | } | 
|---|
 | 41 | bool BaseItem::remove(Pawn* player) | 
|---|
 | 42 | { | 
|---|
 | 43 |         /*if(player->pickUp.Equipment.find(this->getName())!= player->pickUp.Equipment.end()) | 
|---|
 | 44 |         { | 
|---|
 | 45 |         std::multimap<std::string,BaseItem*>::iterator it; | 
|---|
 | 46 |         it=player->pickUp.Equipment.find(this->getName()); | 
|---|
 | 47 |         player->pickUp.Equipment.erase (it); | 
|---|
 | 48 |         return true; | 
|---|
 | 49 |         } | 
|---|
 | 50 |         else | 
|---|
 | 51 |         return false;*/ | 
|---|
 | 52 |         return player->getPickUp().erase(this); | 
|---|
 | 53 | } | 
|---|
 | 54 | bool BaseItem::checkSlot(Pawn* player) | 
|---|
 | 55 | { | 
|---|
 | 56 |         /*std::multimap<std::string,BaseItem*>::iterator it; | 
|---|
 | 57 |         for ( it=player->getPickUp().getEquipment().begin() ; it != player->getPickUp().getEquipment().end(); it++ ) | 
|---|
 | 58 |         { | 
|---|
 | 59 |         if((*it).second->playerBaseClass_==this->playerBaseClass_) | 
|---|
 | 60 |                 //das isch schmarre...machs mit isExactlyA(...) | 
|---|
 | 61 |         return false; | 
|---|
 | 62 |         } | 
|---|
 | 63 |         return true;*/ | 
|---|
 | 64 |         return player->getPickUp().checkSlot(this); | 
|---|
 | 65 | } | 
|---|
 | 66 | void BaseItem::setPlayerBaseClassName(const std::string& name) | 
|---|
 | 67 | { | 
|---|
 | 68 |         this->playerBaseClass_ = ClassByString(name); | 
|---|
 | 69 | } | 
|---|
 | 70 |  | 
|---|
 | 71 | const std::string& BaseItem::getPlayerBaseClassName() const | 
|---|
 | 72 | { | 
|---|
 | 73 |         if (this->playerBaseClass_) | 
|---|
 | 74 |                 return this->playerBaseClass_->getName(); | 
|---|
 | 75 |         else | 
|---|
 | 76 |                 return BLANKSTRING; | 
|---|
 | 77 | } | 
|---|
 | 78 | } | 
|---|