Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

kleinigkeiten an checkSlot usw.

File size: 1.8 KB
RevLine 
[2227]1/* has to be added to player
2   multimap<std::string, Item*> Equipment;*/
3
[2293]4
[2227]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
[2324]11
[2227]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
[2293]31bool Item::addTo (Pawn* player)
[2227]32{
[2342]33
[2324]34        return player->getPickUp().insert(this);
[2293]35        /*if(checkSlot(player)==true)
[2289]36        player->pickUp.Equipment.insert ( std::pair<std::string, Item*>(this->getName(),this) );
37        else
[2293]38        COUT(3) << "swap?" << std::endl;*/
[2227]39}
[2289]40bool Item::remove(Pawn* player)
41{
[2293]42        /*if(player->pickUp.Equipment.find(this->getName())!= player->pickUp.Equipment.end())
[2289]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
[2293]50        return false;*/
51        return player->getPickUp().erase(this);
[2289]52}
53bool Item::checkSlot(Pawn* player)
54{
[2342]55        /*std::multimap<std::string,Item*>::iterator it;
[2324]56        for ( it=player->getPickUp().getEquipment().begin() ; it != player->getPickUp().getEquipment().end(); it++ )
[2289]57        {
58        if((*it).second->playerBaseClass_==this->playerBaseClass_)
[2342]59                //das isch schmarre...machs mit isExactlyA(...)
[2289]60        return false;
61        }
[2342]62        return true;*/
63        return player->getPickUp().checkSlot(this);
[2289]64}
[2227]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.