Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/toonshader/src/orxonox/objects/pickup/ShipEquipment.cc @ 3363

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

Merged presentation branch back to trunk.

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1#include "OrxonoxStableHeaders.h"
2#include "BaseItem.h"
3#include "ShipEquipment.h"
4#include "objects/worldentities/pawns/Pawn.h"
5
6
7namespace orxonox
8{
9/**
10@brief
11    Insert a permanent Item to the Equipment. Is usually called by the addTo function in Items.
12
13@param item
14    pointer to the item which is to be inserted.
15
16@return
17    if new item has sucessfully been added it will return true, in any other case the return value is false.
18*/
19        bool ShipEquipment::insert(BaseItem* item)
20        {
21        if(checkSlot(item)==NULL)
22        {
23                Equipment.insert ( std::pair<std::string, BaseItem*>(item->getName(),item) );
24                return true;
25        }
26        else
27        {
28                COUT(3) << "SWAP?" <<  endl;
29                //Abfrage- irgendne ifschleife...
30                if((checkSlot(item)->dropped(player))==true)
31                {
32                        Equipment.insert ( std::pair<std::string, BaseItem*>(item->getName(),item) );
33                        COUT(3) << "SWAPPED!" <<  endl;
34                        return true;
35                }
36                return false;
37        }
38
39        return false;
40        };
41
42/**
43@brief
44    Erases a permanent Item in the Equipment. Is usually called by the remove/dropped function in Items.
45
46@param item
47    pointer to the item which is to be erased.
48
49@return
50    if new item has sucessfully been erased it will return true, in any other case the return value is false.
51*/
52        bool ShipEquipment::erase (BaseItem* item)
53        {
54        std::multimap<std::string,BaseItem*>::iterator it = Equipment.find(item->getName());
55        if(it != Equipment.end())
56        {
57                Equipment.erase (it);
58                return true;
59        }
60        return false;
61        };
62        /*void print(std::multimap<std::string, BaseItem*> eut)
63        {
64                std::multimap<std::string,BaseItem*>::iterator it;
65                COUT(3) << "Liste:" <<  endl;
66                for ( it=eut.begin() ; it != eut.end(); ++it )
67                    COUT(3) << (*it).first << endl;
68
69        }*/
70/**
71@brief
72    Erases all permanent Items in the Equipment. Its Triggered by hitting the L button.
73
74*/
75        void ShipEquipment::eraseAll()
76        {
77                //print(Equipment);
78                for (std::multimap<std::string,BaseItem*>::iterator it = Equipment.begin(); it != Equipment.end(); )
79                {
80
81                        (it++)->second->dropped(this->getPlayer());
82                }
83                //print(Equipment);
84        }
85
86        BaseItem* ShipEquipment::checkSlot(BaseItem* item)
87        {
88        std::multimap<std::string,BaseItem*>::iterator it;
89        for ( it= getPlayer()->getPickUp().getEquipment().begin() ; it != getPlayer()->getPickUp().getEquipment().end(); it++ )
90        {
91                //if((*it).second->getPlayerBaseClass()==item->getPlayerBaseClass())
92                if(item->isExactlyA((*it).second->getIdentifier()))
93                return (*it).second;
94        }
95        return NULL;
96        };
97
98}
Note: See TracBrowser for help on using the repository browser.