Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickups2/src/orxonox/objects/pickup/Item.cc @ 2691

Last change on this file since 2691 was 2342, checked in by dsommer, 16 years ago

kleinigkeiten an checkSlot usw.

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