Changeset 6996 for code/branches/presentation3/src/modules/pickup
- Timestamp:
- May 27, 2010, 10:44:10 PM (15 years ago)
- Location:
- code/branches/presentation3/src/modules/pickup
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/modules/pickup/PickupManager.cc
r6965 r6996 39 39 #include "core/ScopedSingletonManager.h" 40 40 #include "core/Identifier.h" 41 #include "util/Convert.h" 41 42 #include "interfaces/PickupCarrier.h" 42 43 #include "infos/PlayerInfo.h" … … 64 65 65 66 this->defaultRepresentation_ = new PickupRepresentation(); 66 this->pickupsIndex_ = 0;67 67 68 68 COUT(3) << "PickupManager created." << std::endl; … … 154 154 { 155 155 this->pickupsList_.clear(); 156 this->pickupsIndex_ = 0;157 156 158 157 PlayerInfo* player = GUIManager::getInstance().getPlayer(PickupManager::guiName_s); … … 169 168 for(std::set<Pickupable*>::iterator pickup = pickups.begin(); pickup != pickups.end(); pickup++) 170 169 { 171 this->pickupsList_.insert( *pickup);170 this->pickupsList_.insert(std::pair<Pickupable*, WeakPtr<Pickupable> >(*pickup, WeakPtr<Pickupable>(*pickup))); 172 171 } 173 172 } … … 199 198 void PickupManager::dropPickup(orxonox::Pickupable* pickup) 200 199 { 200 std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); 201 if(pickup == NULL || it == this->pickupsList_.end() || it->second.get() == NULL) 202 return; 203 201 204 if(!pickup->isPickedUp()) 202 205 return; 203 206 204 207 PickupCarrier* carrier = pickup->getCarrier(); 205 208 if(pickup != NULL && carrier != NULL) 209 { 206 210 carrier->drop(pickup); 211 } 207 212 } 208 213 209 214 void PickupManager::usePickup(orxonox::Pickupable* pickup, bool use) 210 215 { 216 std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); 217 if(pickup == NULL || it == this->pickupsList_.end() || it->second.get() == NULL) 218 return; 219 211 220 if(!pickup->isPickedUp()) 212 221 return; -
code/branches/presentation3/src/modules/pickup/PickupManager.h
r6965 r6996 39 39 #include <map> 40 40 #include "util/Singleton.h" 41 #include "core/WeakPtr.h" 41 42 #include "pickup/PickupIdentifier.h" 42 43 #include "PickupRepresentation.h" … … 72 73 // tolua_begin 73 74 int getNumPickups(void); 74 orxonox::Pickupable* popPickup(void) { this->pickupsIndex_++; return *(this->pickupsIterator_++); } 75 int getPickupIndex(void) { return this->pickupsIndex_-1; } 75 orxonox::Pickupable* popPickup(void) { return (this->pickupsIterator_++)->first; } 76 76 orxonox::PickupRepresentation* getPickupRepresentation(orxonox::Pickupable* pickup) { if(pickup != NULL) return this->getRepresentation(pickup->getPickupIdentifier()); return NULL; } 77 77 78 78 void dropPickup(orxonox::Pickupable* pickup); 79 79 void usePickup(orxonox::Pickupable* pickup, bool use); 80 bool isValidPickup(orxonox::Pickupable* pickup) { std::map<Pickupable*, WeakPtr<Pickupable> >::iterator it = this->pickupsList_.find(pickup); if(it == this->pickupsList_.end()) return false; return it->second.get() != NULL; } 80 81 // tolua_end 81 82 … … 87 88 std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations. 88 89 89 std::set<Pickupable*> pickupsList_; 90 std::set<Pickupable*>::iterator pickupsIterator_; 91 int pickupsIndex_; 90 std::map<Pickupable*, WeakPtr<Pickupable> > pickupsList_; 91 std::map<Pickupable*, WeakPtr<Pickupable> >::iterator pickupsIterator_; 92 92 93 93 std::vector<PickupCarrier*>* getAllCarriers(PickupCarrier* carrier);
Note: See TracChangeset
for help on using the changeset viewer.