Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickups2/src/orxonox/objects/pickup/ShipEquipment.cc @ 2663

Last change on this file since 2663 was 2397, checked in by dsommer, 16 years ago

teilweise doxy geaddet und weitere test instanzen

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