source:
code/branches/pickups2/src/orxonox/objects/pickup/ShipEquipment.cc
@
2328
Last change on this file since 2328 was 2324, checked in by dsommer, 16 years ago | |
---|---|
File size: 1.1 KB |
Rev | Line | |
---|---|---|
[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; |
[2290] | 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 | { |
[2324] | 26 | //it->second->dropped(this->getPlayer()); |
[2290] | 27 | Equipment.erase (it); |
28 | return true; | |
29 | } | |
30 | else | |
31 | return false; | |
32 | }; | |
[2324] | 33 | |
34 | void ShipEquipment::eraseAll() | |
[2290] | 35 | { |
[2324] | 36 | |
37 | for (std::multimap<std::string,Item*>::iterator it = Equipment.begin(); it != Equipment.end(); ) | |
38 | { | |
39 | ||
40 | (it++)->second->dropped(this->getPlayer()); | |
41 | } | |
42 | } | |
43 | ||
44 | bool ShipEquipment::checkSlot(Item* item) | |
45 | { | |
[2290] | 46 | std::multimap<std::string,Item*>::iterator it; |
[2324] | 47 | for ( it= getPlayer()->getPickUp().getEquipment().begin() ; it != getPlayer()->getPickUp().getEquipment().end(); it++ ) |
[2290] | 48 | { |
[2324] | 49 | if((*it).second->getPlayerBaseClass()==item->getPlayerBaseClass()) |
[2290] | 50 | return false; |
[2289] | 51 | } |
[2290] | 52 | return true; |
53 | }; | |
[2289] | 54 | } |
Note: See TracBrowser
for help on using the repository browser.