- Timestamp:
- Mar 4, 2010, 11:56:26 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup3/src/orxonox/interfaces/PickupCarrier.h
r6421 r6466 37 37 #include "OrxonoxPrereqs.h" 38 38 #include "core/OrxonoxClass.h" 39 #include "Pickupable.h" 39 40 40 41 #include <set> 42 #include <list> 41 43 42 44 namespace orxonox 43 45 { 44 46 45 class _OrxonoxExport PickupCarrier : public OrxonoxClass47 class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass 46 48 { 49 friend class Pickupable; 47 50 48 51 public: 49 52 PickupCarrier(); 50 53 virtual ~PickupCarrier() {} 54 55 //TODO: Secure uniqueness of each item in the set, if neccessary, check. 56 inline bool pickup(Pickupable* pickup) 57 { 58 bool pickedUp = this->pickups_.insert(pickup).second; 59 if(pickedUp) pickup->pickedUp(this); 60 return pickedUp; 61 } 62 63 inline bool drop(Pickupable* pickup) 64 { 65 bool dropped = this->pickups_.erase(pickup) == 1; 66 if(dropped) 67 { 68 pickup->dropped(); 69 //TODO: Create Spawner. 70 } 71 return dropped; 72 } 73 74 inline bool isTarget(Pickupable* pickup) 75 { 76 if(pickup->isTarget(this)) 77 return true; 78 const std::list<PickupCarrier*>* children = this->getChildren(); 79 for(std::list<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++) 80 { 81 if((*it)->isTarget(pickup)) 82 return true; 83 } 84 85 return false; 86 } 87 88 protected: 89 //TODO: Good return type? 90 virtual const std::list<PickupCarrier*>* getChildren(void) = 0; 91 virtual PickupCarrier* getParent(void) = 0; 51 92 52 93 private: 94 std::set<Pickupable*> pickups_; 53 95 54 std::set<Pickupable*> pickups_;55 96 56 97 };
Note: See TracChangeset
for help on using the changeset viewer.