Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 20, 2009, 9:01:17 PM (15 years ago)
Author:
danielh
Message:
  • Added helper method to HumanController to get it's ControllableEntity as a Pawn
  • Removed tooltip, added default (empty) values for text and image from BaseItem
  • Fixed tolua in BaseItem.h
  • Added object to PickupCollection for the current UsableItem
  • Moved most inventory logic from Lua to PickupInventory (still slow)

TODO

  • Re-use of CEGUI item windows, destroying and creating them on each update is slow, very slow
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc

    r2972 r3001  
    4949    {
    5050        this->bBlockRemovals_ = false;
     51        this->currentUsable_ = NULL;
    5152    }
    5253
     
    6465        if (this->checkSlot(item))
    6566        {
     67            Identifier* ident = Class(UsableItem);
     68            if(this->currentUsable_ == NULL && item->isA(ident))
     69                this->currentUsable_ = dynamic_cast<UsableItem*>(item);
     70
    6671            this->items_.insert( std::pair<std::string, BaseItem*> (item->getPickupIdentifier(), item) );
    6772            return true;
     
    99104                (*it).second->dropped((*it).second->getOwner());
    100105        }
     106        this->currentUsable_ = NULL;
    101107        this->items_.clear();
    102108        this->bBlockRemovals_ = false;
     
    130136    void PickupCollection::useItem()
    131137    {
    132         Identifier* ident = Class(UsableItem);
    133         for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
    134         {
    135             if ((*it).second->isA(ident))
    136             {
    137                 UsableItem* asUsable = dynamic_cast<UsableItem*>((*it).second);
    138                 asUsable->used(this->owner_);
    139                 return;
    140             }
    141         }
     138        if(this->currentUsable_)
     139            this->currentUsable_->used(this->owner_);
    142140    }
    143141    /**
     
    160158            return;
    161159
     160        if (item == this->currentUsable_ || (this->currentUsable_ && removeAllOfType && this->currentUsable_->getPickupIdentifier() == item->getPickupIdentifier()))
     161        {
     162            std::deque<UsableItem*> usables = this->getUsableItems();
     163
     164            if(usables.size() > 0)
     165                this->currentUsable_ = usables.at(0);
     166            else
     167                this->currentUsable_ = NULL;
     168        }
    162169        if (removeAllOfType)
    163170        {
Note: See TracChangeset for help on using the changeset viewer.