Changeset 9348 for code/trunk/src/modules/pickup/Pickup.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/Pickup.cc
r8864 r9348 37 37 #include "util/StringUtils.h" 38 38 39 #include "pickup/PickupIdentifier.h" 40 41 #include "DroppedPickup.h" 39 #include "PickupSpawner.h" 42 40 43 41 namespace orxonox … … 86 84 /** 87 85 @brief 88 Initializes the PickupIdentififer of this Pickup.89 */90 void Pickup::initializeIdentifier(void)91 {92 std::string val1 = this->getActivationType();93 std::string type1 = "activationType";94 this->pickupIdentifier_->addParameter(type1, val1);95 96 std::string val2 = this->getDurationType();97 std::string type2 = "durationType";98 this->pickupIdentifier_->addParameter(type2, val2);99 }100 101 /**102 @brief103 86 Method for creating a Pickup object through XML. 104 87 */ … … 107 90 SUPER(Pickup, XMLPort, xmlelement, mode); 108 91 109 XMLPortParam(Pickup, "activationType", setActivationType, getActivationType, xmlelement, mode); 110 XMLPortParam(Pickup, "durationType", setDurationType, getDurationType, xmlelement, mode); 111 112 this->initializeIdentifier(); 92 XMLPortParam(Pickup, "representation", setRepresentationName, getRepresentationName, xmlelement, mode); 93 XMLPortParam(Pickup, "activationType", setActivationTypeAsString, getActivationTypeAsString, xmlelement, mode); 94 XMLPortParam(Pickup, "durationType", setDurationTypeAsString, getDurationTypeAsString, xmlelement, mode); 113 95 } 114 96 … … 119 101 Returns a string containing the activation type. 120 102 */ 121 const std::string& Pickup::getActivationType (void) const103 const std::string& Pickup::getActivationTypeAsString(void) const 122 104 { 123 switch(this-> activationType_)105 switch(this->getActivationType()) 124 106 { 125 107 case pickupActivationType::immediate: … … 138 120 Returns a string containing the duration type. 139 121 */ 140 const std::string& Pickup::getDurationType (void) const122 const std::string& Pickup::getDurationTypeAsString(void) const 141 123 { 142 switch(this-> durationType_)124 switch(this->getDurationType()) 143 125 { 144 126 case pickupDurationType::once: … … 157 139 The activation type of the Pickup as a string. 158 140 */ 159 void Pickup::setActivationType (const std::string& type)141 void Pickup::setActivationTypeAsString(const std::string& type) 160 142 { 161 143 if(type == Pickup::activationTypeImmediate_s) 162 this-> activationType_ = pickupActivationType::immediate;144 this->setActivationType(pickupActivationType::immediate); 163 145 else if(type == Pickup::activationTypeOnUse_s) 164 this-> activationType_ = pickupActivationType::onUse;146 this->setActivationType(pickupActivationType::onUse); 165 147 else 166 148 orxout(internal_error, context::pickups) << "Invalid activationType '" << type << "' in " << this->getIdentifier()->getName() << "." << endl; … … 173 155 The duration type of the Pickup as a string. 174 156 */ 175 void Pickup::setDurationType (const std::string& type)157 void Pickup::setDurationTypeAsString(const std::string& type) 176 158 { 177 159 if(type == Pickup::durationTypeOnce_s) 178 this-> durationType_ = pickupDurationType::once;160 this->setDurationType(pickupDurationType::once); 179 161 else if(type == Pickup::durationTypeContinuous_s) 180 this-> durationType_ = pickupDurationType::continuous;162 this->setDurationType(pickupDurationType::continuous); 181 163 else 182 164 orxout(internal_error, context::pickups) << "Invalid durationType '" << type << "' in " << this->getIdentifier()->getName() << "." << endl; … … 199 181 /** 200 182 @brief 201 Creates a duplicate of the OrxonoxClass.202 @param item203 A reference to the pointer of the item that we're duplicating.204 */205 void Pickup::clone(OrxonoxClass*& item)206 {207 if(item == NULL)208 item = new Pickup(this);209 210 SUPER(Pickup, clone, item);211 212 Pickup* pickup = dynamic_cast<Pickup*>(item);213 pickup->setActivationTypeDirect(this->getActivationTypeDirect());214 pickup->setDurationTypeDirect(this->getDurationTypeDirect());215 216 pickup->initializeIdentifier();217 }218 219 /**220 @brief221 183 Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 222 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.:223 DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position);224 184 @return 225 185 Returns true if a spawner was created, false if not. … … 227 187 bool Pickup::createSpawner(void) 228 188 { 229 newDroppedPickup(this, this, this->getCarrier());189 PickupSpawner::createDroppedPickup(this, this, this->getCarrier()); 230 190 return true; 231 191 }
Note: See TracChangeset
for help on using the changeset viewer.