Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem5/src/orxonox/objects/pickup/BaseItem.cc @ 2961

Last change on this file since 2961 was 2662, checked in by rgrieder, 16 years ago

Merged presentation branch back to trunk.

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