[2293] | 1 | #include "Item.h" |
---|
[2294] | 2 | #include "ShipEquipment.h" |
---|
[2324] | 3 | #include "objects/worldentities/pawns/Pawn.h" |
---|
[2289] | 4 | |
---|
| 5 | |
---|
| 6 | namespace orxonox |
---|
| 7 | { |
---|
[2324] | 8 | |
---|
[2293] | 9 | bool ShipEquipment::insert(Item* item) |
---|
[2289] | 10 | { |
---|
[2324] | 11 | if(checkSlot(item)==true) |
---|
| 12 | { |
---|
[2290] | 13 | Equipment.insert ( std::pair<std::string, Item*>(item->getName(),item) ); |
---|
[2324] | 14 | return true; |
---|
| 15 | } |
---|
[2290] | 16 | COUT(3) << "swap?" << std::endl; |
---|
[2324] | 17 | return false; |
---|
[2342] | 18 | |
---|
[2324] | 19 | return false; |
---|
[2290] | 20 | }; |
---|
[2293] | 21 | bool ShipEquipment::erase (Item* item) |
---|
[2290] | 22 | { |
---|
[2324] | 23 | std::multimap<std::string,Item*>::iterator it = Equipment.find(item->getName()); |
---|
| 24 | if(it != Equipment.end()) |
---|
[2290] | 25 | { |
---|
| 26 | Equipment.erase (it); |
---|
| 27 | return true; |
---|
| 28 | } |
---|
[2342] | 29 | return false; |
---|
[2290] | 30 | }; |
---|
[2342] | 31 | /*void print(std::multimap<std::string, Item*> eut) |
---|
| 32 | { |
---|
| 33 | std::multimap<std::string,Item*>::iterator it; |
---|
| 34 | COUT(3) << "Liste:" << endl; |
---|
| 35 | for ( it=eut.begin() ; it != eut.end(); ++it ) |
---|
| 36 | COUT(3) << (*it).first << endl; |
---|
[2324] | 37 | |
---|
[2342] | 38 | }*/ |
---|
[2324] | 39 | void ShipEquipment::eraseAll() |
---|
[2290] | 40 | { |
---|
[2342] | 41 | //print(Equipment); |
---|
[2324] | 42 | for (std::multimap<std::string,Item*>::iterator it = Equipment.begin(); it != Equipment.end(); ) |
---|
| 43 | { |
---|
[2342] | 44 | |
---|
[2324] | 45 | (it++)->second->dropped(this->getPlayer()); |
---|
| 46 | } |
---|
[2342] | 47 | //print(Equipment); |
---|
[2324] | 48 | } |
---|
| 49 | |
---|
| 50 | bool ShipEquipment::checkSlot(Item* item) |
---|
| 51 | { |
---|
[2290] | 52 | std::multimap<std::string,Item*>::iterator it; |
---|
[2324] | 53 | for ( it= getPlayer()->getPickUp().getEquipment().begin() ; it != getPlayer()->getPickUp().getEquipment().end(); it++ ) |
---|
[2290] | 54 | { |
---|
[2342] | 55 | //if((*it).second->getPlayerBaseClass()==item->getPlayerBaseClass()) |
---|
| 56 | if(item->isExactlyA((*it).second->getIdentifier())) |
---|
[2290] | 57 | return false; |
---|
[2289] | 58 | } |
---|
[2290] | 59 | return true; |
---|
| 60 | }; |
---|
[2289] | 61 | } |
---|