Changeset 7547 for code/trunk/src/modules/pickup/items/MetaPickup.cc
- Timestamp:
- Oct 16, 2010, 12:37:09 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/items/MetaPickup.cc
r7533 r7547 34 34 #include "core/CoreIncludes.h" 35 35 #include "core/XMLPort.h" 36 #include "worldentities/pawns/Pawn.h" 36 37 37 #include "interfaces/PickupCarrier.h" 38 38 #include "pickup/PickupIdentifier.h" 39 #include "worldentities/pawns/Pawn.h" 39 40 40 41 #include "MetaPickup.h" … … 79 80 this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier()); 80 81 81 this->setActivationTypeDirect(pickupActivationType::immediate);82 82 this->setDurationTypeDirect(pickupDurationType::once); 83 83 this->metaType_ = pickupMetaType::none; … … 117 117 SUPER(MetaPickup, changedUsed); 118 118 119 // ! If the MetaPickup transited to used.120 if(this->isUsed() )119 // If the MetaPickup transited to used, and the metaType is not none. 120 if(this->isUsed() && this->metaType_ != pickupMetaType::none) 121 121 { 122 122 PickupCarrier* carrier = this->getCarrier(); 123 123 if(this->getMetaTypeDirect() != pickupMetaType::none && carrier != NULL) 124 124 { 125 // If the metaType is destroyCarrier, then the PickupCarrier is destroyed. 125 126 if(this->getMetaTypeDirect() == pickupMetaType::destroyCarrier) 126 127 { … … 131 132 } 132 133 std::set<Pickupable*> pickups = carrier->getPickups(); 133 // ! Set all Pickupables carried by the PickupCarrier either to used or drop them, depending on the meta type.134 // Iterate over all Pickupables of the PickupCarrier. 134 135 for(std::set<Pickupable*>::iterator it = pickups.begin(); it != pickups.end(); it++) 135 136 { 136 Pickup* pickup = dynamic_cast<Pickup*>(*it); 137 if(this->getMetaTypeDirect() == pickupMetaType::use) 137 Pickupable* pickup = (*it); 138 if(pickup == NULL || pickup == this) 139 continue; 140 141 // If the metaType is use, then the Pickupable is set to used. 142 if(this->getMetaTypeDirect() == pickupMetaType::use && !pickup->isUsed()) 138 143 { 139 if(pickup != NULL && pickup != this && pickup->isOnUse() && !pickup->isUsed()) 140 { 141 pickup->setUsed(true); 142 } 144 pickup->setUsed(true); 143 145 } 144 if(this->getMetaTypeDirect() == pickupMetaType::drop) 146 // If the metaType is drop, then the Pickupable is dropped. 147 else if(this->getMetaTypeDirect() == pickupMetaType::drop) 145 148 { 146 if(pickup != NULL && pickup != this) 147 { 148 pickup->drop(); 149 } 149 pickup->drop(); 150 150 } 151 if(this->getMetaTypeDirect() == pickupMetaType::destroy) 151 // If the metaType is destroy, then the Pickupable is destroyed. 152 else if(this->getMetaTypeDirect() == pickupMetaType::destroy) 152 153 { 153 if(pickup != NULL && pickup != this) 154 { 155 pickup->Pickupable::destroy(); 156 } 154 pickup->Pickupable::destroy(); 157 155 } 158 156 } … … 187 185 Returns a string with the meta type of the MetaPickup. 188 186 */ 189 const std::string& MetaPickup::getMetaType(void) 187 const std::string& MetaPickup::getMetaType(void) const 190 188 { 191 189 switch(this->getMetaTypeDirect())
Note: See TracChangeset
for help on using the changeset viewer.