- Timestamp:
- May 20, 2009, 9:01:17 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc
r2972 r3001 49 49 { 50 50 this->bBlockRemovals_ = false; 51 this->currentUsable_ = NULL; 51 52 } 52 53 … … 64 65 if (this->checkSlot(item)) 65 66 { 67 Identifier* ident = Class(UsableItem); 68 if(this->currentUsable_ == NULL && item->isA(ident)) 69 this->currentUsable_ = dynamic_cast<UsableItem*>(item); 70 66 71 this->items_.insert( std::pair<std::string, BaseItem*> (item->getPickupIdentifier(), item) ); 67 72 return true; … … 99 104 (*it).second->dropped((*it).second->getOwner()); 100 105 } 106 this->currentUsable_ = NULL; 101 107 this->items_.clear(); 102 108 this->bBlockRemovals_ = false; … … 130 136 void PickupCollection::useItem() 131 137 { 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_); 142 140 } 143 141 /** … … 160 158 return; 161 159 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 } 162 169 if (removeAllOfType) 163 170 {
Note: See TracChangeset
for help on using the changeset viewer.