- Timestamp:
- Jun 10, 2012, 11:01:40 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2012merge/src/modules/pickup/CollectiblePickup.cc
r7494 r9290 45 45 Registers the object and initializes variables. 46 46 */ 47 CollectiblePickup::CollectiblePickup() : isInCollection_(false)47 CollectiblePickup::CollectiblePickup() : collection_(NULL) 48 48 { 49 49 RegisterObject(CollectiblePickup); 50 51 this->collection_ = NULL;52 50 } 53 51 … … 58 56 CollectiblePickup::~CollectiblePickup() 59 57 { 60 61 } 62 63 /** 64 @brief 65 Is called by OrxonoxClass::destroy() before the object is actually destroyed. 66 */ 67 void CollectiblePickup::preDestroy(void) 68 { 69 this->Pickupable::preDestroy(); 70 71 // The PickupCollection has to be destroyed as well. 72 if(this->isInCollection()) 73 this->collection_->Pickupable::destroy(); 74 } 75 76 /** 77 @brief 78 Destroys a Pickupable. 79 */ 80 void CollectiblePickup::destroyPickup(void) 81 { 82 if(!this->isInCollection()) // If the CollectiblePickup is not in a PickupCollection the destroyPickup method of Pickupable is called. 83 this->Pickupable::destroyPickup(); 84 else // Else the ColectiblePickup is dropped and disabled, 85 { 86 this->drop(false); 87 if(this->isInCollection() && this->isEnabled()) // It is only disabled if it is enabled and still ina PickupCollection after having been dropped. 88 { 89 this->setDisabled(); 90 this->collection_->pickupDisabled(); 91 } 92 } 58 if (this->isInCollection()) 59 this->collection_->removePickupable(this); 93 60 } 94 61 … … 131 98 /** 132 99 @brief 133 Adds this CollectiblePickup to the inputPickupCollection.100 Notifies this CollectiblePickup that it was added to a PickupCollection. 134 101 @param collection 135 102 A pointer to the PickupCollection to which the CollectiblePickup should be added. 136 @return137 Returns true if the CollectiblePickup was successfully added to the PickupCollection.138 103 */ 139 bool CollectiblePickup::addToCollection(PickupCollection* collection)104 void CollectiblePickup::wasAddedToCollection(PickupCollection* collection) 140 105 { 141 if(this->isInCollection() || collection == NULL) //If the CollectiblePickup already is in a PickupCollection or if the input pointer is NULL.142 return false;143 144 this->isInCollection_ = true;145 106 this->collection_ = collection; 146 return true;147 107 } 148 108 149 109 /** 150 110 @brief 151 Removes this CollectiblePickup from its PickupCollection. 152 @return 153 Returns true if the CollectiblePickup was succcessfully removed. 111 Notifies this CollectiblePickup that it was removed from its PickupCollection. 154 112 */ 155 bool CollectiblePickup::removeFromCollection(void)113 void CollectiblePickup::wasRemovedFromCollection(void) 156 114 { 157 if(!this->isInCollection()) //If the CollectiblePickup is not in a PickupCollection.158 return false;159 160 this->isInCollection_ = false;161 115 this->collection_ = NULL; 162 return true;163 116 } 164 165 117 }
Note: See TracChangeset
for help on using the changeset viewer.