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