Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Aufnehmen von festen Item und wieder ablegen

File size: 1.1 KB
Line 
1#include "Item.h"
2#include "ShipEquipment.h"
3#include "objects/worldentities/pawns/Pawn.h"
4
5
6namespace orxonox
7{
8
9        bool ShipEquipment::insert(Item* item)
10        {
11        if(checkSlot(item)==true)
12        {
13                Equipment.insert ( std::pair<std::string, Item*>(item->getName(),item) );
14                return true;
15        }
16                COUT(3) << "swap?" << std::endl;
17                return false;
18       
19        return false;
20        };
21        bool ShipEquipment::erase (Item* item)
22        {
23        std::multimap<std::string,Item*>::iterator it = Equipment.find(item->getName());
24        if(it != Equipment.end())
25        {
26                //it->second->dropped(this->getPlayer());
27                Equipment.erase (it);
28                return true;
29        }
30        else
31                return false;
32        };
33
34        void ShipEquipment::eraseAll()
35        {
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        {
46        std::multimap<std::string,Item*>::iterator it;
47        for ( it= getPlayer()->getPickUp().getEquipment().begin() ; it != getPlayer()->getPickUp().getEquipment().end(); it++ )
48        {
49                if((*it).second->getPlayerBaseClass()==item->getPlayerBaseClass())
50                return false;
51        }
52        return true;
53        };
54}
Note: See TracBrowser for help on using the repository browser.