Changeset 6475 for code/branches/pickup3/src/modules/pickup/Pickup.cc
- Timestamp:
- Mar 5, 2010, 6:26:54 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup3/src/modules/pickup/Pickup.cc
r6474 r6475 30 30 31 31 #include "core/CoreIncludes.h" 32 #include "util/StringUtils.h" 33 #include "pickup/PickupIdentifier.h" 34 #include "DroppedPickup.h" 32 35 33 36 namespace orxonox … … 38 41 /*static*/ const std::string Pickup::durationTypeOnce_s = "once"; 39 42 /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous"; 40 /*static*/ const std::string Pickup::blankString_s = ""; 41 42 //TODO: Should this bee here? Does it work without? 43 44 //TODO: Should this be here? Does it work without? 43 45 CreateFactory(Pickup); 44 46 … … 47 49 RegisterObject(Pickup); 48 50 51 this->initialize(); 49 52 } 50 53 … … 54 57 } 55 58 59 /** 60 @brief 61 Initializes the member variables. 62 */ 63 void Pickup::initialize(void) 64 { 65 this->activationType_ = pickupActivationType::immediate; 66 this->durationType_ = pickupDurationType::once; 67 } 68 69 /** 70 @brief 71 Initializes the PickupIdentififer of this Pickup. 72 */ 56 73 void Pickup::initializeIdentifier(void) 57 74 { 58 this->pickupIdentifier_.addClass(this->getIdentifier()); 75 //TODO: Check whether this could not be done in the Constructor if Pickupable. Would be much more convenient. 76 this->pickupIdentifier_->addClass(this->getIdentifier()); 59 77 60 78 //TODO: Works? 61 79 std::string val1 = this->getActivationType(); 62 80 std::string type1 = "activationType"; 63 this->pickupIdentifier_ .addParameter(type1, val1);81 this->pickupIdentifier_->addParameter(type1, val1); 64 82 65 83 std::string val2 = this->getDurationType(); 66 84 std::string type2 = "durationType"; 67 this->pickupIdentifier_.addParameter(type2, val2); 68 } 69 85 this->pickupIdentifier_->addParameter(type2, val2); 86 } 87 88 /** 89 @brief 90 Method for creating a Pickup object through XML. 91 */ 70 92 void Pickup::XMLPort(Element& xmlelement, XMLPort::Mode mode) 71 93 { … … 81 103 @brief 82 104 Get the activation type of the pickup. 83 @ param buffer84 The buffer to store the activation type as string in.105 @return 106 Returns a string containing the activation type. 85 107 */ 86 108 const std::string& Pickup::getActivationType(void) … … 93 115 return activationTypeOnUse_s; 94 116 default: 95 return blankString_s;117 return BLANKSTRING; 96 118 } 97 119 } … … 100 122 @brief 101 123 Get the duration type of the pickup. 102 @ param buffer103 The buffer to store the duration type as string in.124 @return 125 Returns a string containing the duration type. 104 126 */ 105 127 const std::string& Pickup::getDurationType(void) … … 112 134 return durationTypeContinuous_s; 113 135 default: 114 return blankString_s;136 return BLANKSTRING; 115 137 } 116 138 } … … 162 184 /** 163 185 @brief 164 Creates a duplicate of the pickup. 186 Should be called when the pickup has transited from picked up to dropped or the other way around. 187 Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedCarrier); to their changedCarrier method. 188 */ 189 void Pickup::changedCarrier(void) 190 { 191 SUPER(Pickup, changedCarrier); 192 193 //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up. 194 if(this->isPickedUp() && this->isImmediate()) 195 { 196 this->setUsed(true); 197 } 198 } 199 200 /** 201 @brief 202 Creates a duplicate of the Pickup. 165 203 @return 166 204 Returns the clone of this pickup as a pointer to a Pickupable. … … 179 217 pickup->initializeIdentifier(); 180 218 } 181 182 void Pickup::changedCarrier(void) 183 { 184 SUPER(Pickup, changedCarrier); 185 186 if(this->isPickedUp() && this->isImmediate()) 187 { 188 this->setUsed(true); 189 } 219 220 /** 221 @brief 222 Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 223 This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.: 224 DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position); 225 @param position 226 The position at which the PickupSpawner should be placed. 227 @return 228 Returns true if a spawner was created, false if not. 229 */ 230 bool Pickup::createSpawner(const Vector3& position) 231 { 232 DroppedPickup::DroppedPickup(this, this, position); 233 return true; 190 234 } 191 235
Note: See TracChangeset
for help on using the changeset viewer.