Changeset 9348 for code/trunk/src/modules/pickup/CollectiblePickup.cc
- Timestamp:
- Aug 30, 2012, 11:08:17 PM (12 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore
-
old new 1 .project 1 2 build 2 3 codeblocks 4 dependencies 3 5 vs 4 dependencies
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
code/trunk/src/modules/pickup/CollectiblePickup.cc
r7494 r9348 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 } 93 } 94 95 /** 96 @brief 97 Is called by the PickupCarrier when it is being destroyed. 98 */ 99 void CollectiblePickup::carrierDestroyed(void) 100 { 101 if(!this->isInCollection()) 102 this->Pickupable::destroy(); 103 else // If the CollectiblePickup is part of a PickupCollection it is just dropped instead of destroyed. 104 this->drop(false); 58 if (this->isInCollection()) 59 this->collection_->removePickupable(this); 105 60 } 106 61 … … 131 86 /** 132 87 @brief 133 Adds this CollectiblePickup to the inputPickupCollection.88 Notifies this CollectiblePickup that it was added to a PickupCollection. 134 89 @param collection 135 90 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 91 */ 139 bool CollectiblePickup::addToCollection(PickupCollection* collection)92 void CollectiblePickup::wasAddedToCollection(PickupCollection* collection) 140 93 { 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 94 this->collection_ = collection; 146 return true;147 95 } 148 96 149 97 /** 150 98 @brief 151 Removes this CollectiblePickup from its PickupCollection. 152 @return 153 Returns true if the CollectiblePickup was succcessfully removed. 99 Notifies this CollectiblePickup that it was removed from its PickupCollection. 154 100 */ 155 bool CollectiblePickup::removeFromCollection(void)101 void CollectiblePickup::wasRemovedFromCollection(void) 156 102 { 157 if(!this->isInCollection()) //If the CollectiblePickup is not in a PickupCollection.158 return false;159 160 this->isInCollection_ = false;161 103 this->collection_ = NULL; 162 return true;163 104 } 164 165 105 }
Note: See TracChangeset
for help on using the changeset viewer.