Changeset 10998 for code/branches/cpp11_v2/src/modules/pickup/items
- Timestamp:
- Dec 30, 2015, 1:59:38 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/modules/pickup/items
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/modules/pickup/items/DronePickup.cc
r10765 r10998 74 74 { 75 75 this->addTarget(ClassIdentifier<Pawn>::getIdentifier()); 76 this->setDurationType( pickupDurationType::once);76 this->setDurationType(PickupDurationType::once); 77 77 this->droneTemplate_ = ""; 78 78 } -
code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.cc
r10765 r10998 77 77 this->health_ = 0.0f; 78 78 this->healthRate_ = 0.0f; 79 this->healthType_ = pickupHealthType::limited;79 this->healthType_ = PickupHealthType::limited; 80 80 this->maxHealthSave_ = 0.0f; 81 81 this->maxHealthOverwrite_ = 0.0f; … … 127 127 switch(this->getHealthType()) 128 128 { 129 case pickupHealthType::permanent:129 case PickupHealthType::permanent: 130 130 if(pawn->getMaxHealth() < fullHealth) 131 131 pawn->setMaxHealth(fullHealth); 132 case pickupHealthType::limited:132 case PickupHealthType::limited: 133 133 pawn->addHealth(health); 134 134 break; 135 case pickupHealthType::temporary:135 case PickupHealthType::temporary: 136 136 if(pawn->getMaxHealth() > fullHealth) 137 137 { … … 174 174 switch(this->getHealthType()) 175 175 { 176 case pickupHealthType::permanent:176 case PickupHealthType::permanent: 177 177 health = pawn->getHealth()+this->getHealth(); 178 178 if(pawn->getMaxHealth() < health) 179 179 pawn->setMaxHealth(health); 180 case pickupHealthType::limited:180 case PickupHealthType::limited: 181 181 pawn->addHealth(this->getHealth()); 182 182 break; 183 case pickupHealthType::temporary:183 case PickupHealthType::temporary: 184 184 health = pawn->getHealth()+this->getHealth(); 185 185 if(pawn->getMaxHealth() < health) … … 201 201 else 202 202 { 203 if(this->getHealthType() == pickupHealthType::temporary)203 if(this->getHealthType() == PickupHealthType::temporary) 204 204 { 205 205 PickupCarrier* carrier = this->getCarrier(); … … 256 256 switch(this->getHealthType()) 257 257 { 258 case pickupHealthType::limited:258 case PickupHealthType::limited: 259 259 return HealthPickup::healthTypeLimited_s; 260 case pickupHealthType::temporary:260 case PickupHealthType::temporary: 261 261 return HealthPickup::healthTypeTemporary_s; 262 case pickupHealthType::permanent:262 case PickupHealthType::permanent: 263 263 return HealthPickup::healthTypePermanent_s; 264 264 default: … … 308 308 { 309 309 if(type == HealthPickup::healthTypeLimited_s) 310 this->setHealthType( pickupHealthType::limited);310 this->setHealthType(PickupHealthType::limited); 311 311 else if(type == HealthPickup::healthTypeTemporary_s) 312 this->setHealthType( pickupHealthType::temporary);312 this->setHealthType(PickupHealthType::temporary); 313 313 else if(type == HealthPickup::healthTypePermanent_s) 314 this->setHealthType( pickupHealthType::permanent);314 this->setHealthType(PickupHealthType::permanent); 315 315 else 316 316 orxout(internal_error, context::pickups) << "Invalid healthType '" << type << "' in HealthPickup." << endl; -
code/branches/cpp11_v2/src/modules/pickup/items/HealthPickup.h
r9667 r10998 51 51 @ingroup PickupItems 52 52 */ 53 namespace pickupHealthType53 enum class PickupHealthType 54 54 { 55 enum Value 56 { 57 limited, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" only increases the users health to its maximum health. 58 temporary, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" temporarily increases the users health even above its maximum health, but only as long as it is in use. 59 permanent //!< Means that the @ref orxonox::HealthPickup "HealthPickup" increases the users health even above its maximum health and increases the maximum health permanently such that it matches the new health. 60 }; 61 } 55 limited, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" only increases the users health to its maximum health. 56 temporary, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" temporarily increases the users health even above its maximum health, but only as long as it is in use. 57 permanent //!< Means that the @ref orxonox::HealthPickup "HealthPickup" increases the users health even above its maximum health and increases the maximum health permanently such that it matches the new health. 58 }; 62 59 63 60 /** … … 115 112 @return Returns the health type as an enum. 116 113 */ 117 inline pickupHealthType::Value getHealthType(void) const114 inline PickupHealthType getHealthType(void) const 118 115 { return this->healthType_; } 119 116 const std::string& getHealthTypeAsString(void) const; //!< Get the health type of this pickup. … … 127 124 @param type The type of this pickup as an enum. 128 125 */ 129 inline void setHealthType( pickupHealthType::Value type)126 inline void setHealthType(PickupHealthType type) 130 127 { this->healthType_ = type; } 131 128 void setHealthTypeAsString(const std::string& type); //!< Set the type of the HealthPickup. … … 139 136 float maxHealthSave_; //!< Helper to remember what the actual maxHealth of the Pawn was before we changed it. 140 137 float maxHealthOverwrite_; //!< Helper to remember with which value we overwrote the maxHealh, to detect if someone else changed it as well. 141 pickupHealthType::Value healthType_; //!< The type of the HealthPickup.138 PickupHealthType healthType_; //!< The type of the HealthPickup. 142 139 143 140 //! Strings for the health types. -
code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.cc
r10916 r10998 79 79 this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier()); 80 80 81 this->setDurationType( pickupDurationType::once);82 this->metaType_ = pickupMetaType::none;81 this->setDurationType(PickupDurationType::once); 82 this->metaType_ = PickupMetaType::none; 83 83 } 84 84 … … 104 104 105 105 // If the MetaPickup transited to used, and the metaType is not none. 106 if(this->isUsed() && this->metaType_ != pickupMetaType::none)106 if(this->isUsed() && this->metaType_ != PickupMetaType::none) 107 107 { 108 108 PickupCarrier* carrier = this->getCarrier(); 109 if(this->getMetaType() != pickupMetaType::none && carrier != nullptr)109 if(this->getMetaType() != PickupMetaType::none && carrier != nullptr) 110 110 { 111 111 // If the metaType is destroyCarrier, then the PickupCarrier is destroyed. 112 if(this->getMetaType() == pickupMetaType::destroyCarrier)112 if(this->getMetaType() == PickupMetaType::destroyCarrier) 113 113 { 114 114 Pawn* pawn = orxonox_cast<Pawn*>(carrier); … … 124 124 125 125 // If the metaType is use, then the Pickupable is set to used. 126 if(this->getMetaType() == pickupMetaType::use && !pickup->isUsed())126 if(this->getMetaType() == PickupMetaType::use && !pickup->isUsed()) 127 127 { 128 128 pickup->setUsed(true); 129 129 } 130 130 // If the metaType is drop, then the Pickupable is dropped. 131 else if(this->getMetaType() == pickupMetaType::drop)131 else if(this->getMetaType() == PickupMetaType::drop) 132 132 { 133 133 pickup->drop(); 134 134 } 135 135 // If the metaType is destroy, then the Pickupable is destroyed. 136 else if(this->getMetaType() == pickupMetaType::destroy)136 else if(this->getMetaType() == PickupMetaType::destroy) 137 137 { 138 138 pickup->Pickupable::destroy(); … … 154 154 switch(this->getMetaType()) 155 155 { 156 case pickupMetaType::none:156 case PickupMetaType::none: 157 157 return MetaPickup::metaTypeNone_s; 158 case pickupMetaType::use:158 case PickupMetaType::use: 159 159 return MetaPickup::metaTypeUse_s; 160 case pickupMetaType::drop:160 case PickupMetaType::drop: 161 161 return MetaPickup::metaTypeDrop_s; 162 case pickupMetaType::destroy:162 case PickupMetaType::destroy: 163 163 return MetaPickup::metaTypeDestroy_s; 164 case pickupMetaType::destroyCarrier:164 case PickupMetaType::destroyCarrier: 165 165 return MetaPickup::metaTypeDestroyCarrier_s; 166 166 default: … … 179 179 if(type == MetaPickup::metaTypeNone_s) 180 180 { 181 this->setMetaType( pickupMetaType::none);181 this->setMetaType(PickupMetaType::none); 182 182 } 183 183 else if(type == MetaPickup::metaTypeUse_s) 184 184 { 185 this->setMetaType( pickupMetaType::use);185 this->setMetaType(PickupMetaType::use); 186 186 } 187 187 else if(type == MetaPickup::metaTypeDrop_s) 188 188 { 189 this->setMetaType( pickupMetaType::drop);189 this->setMetaType(PickupMetaType::drop); 190 190 } 191 191 else if(type == MetaPickup::metaTypeDestroy_s) 192 192 { 193 this->setMetaType( pickupMetaType::destroy);193 this->setMetaType(PickupMetaType::destroy); 194 194 } 195 195 else if(type == MetaPickup::metaTypeDestroyCarrier_s) 196 196 { 197 this->setMetaType( pickupMetaType::destroyCarrier);197 this->setMetaType(PickupMetaType::destroyCarrier); 198 198 } 199 199 else -
code/branches/cpp11_v2/src/modules/pickup/items/MetaPickup.h
r9667 r10998 48 48 @ingroup PickupItems 49 49 */ 50 namespace pickupMetaType50 enum class PickupMetaType 51 51 { 52 enum Value 53 { 54 none, //!< The @ref orxonox::MetaPickup "MetaPickup" does nothing. 55 use, //!< The @ref orxonox::MetaPickup "MetaPickup" uses all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables". 56 drop, //!< The @ref orxonox::MetaPickup "MetaPickup" drops all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables". 57 destroy, //!< The @ref orxonox::MetaPickup "MetaPickup" destroys all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables". 58 destroyCarrier //!< The @ref orxonox::MetaPickup "MetaPickup" destroys the @ref orxonox::PickupCarrier "PickupCarrier". 59 }; 60 } 52 none, //!< The @ref orxonox::MetaPickup "MetaPickup" does nothing. 53 use, //!< The @ref orxonox::MetaPickup "MetaPickup" uses all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables". 54 drop, //!< The @ref orxonox::MetaPickup "MetaPickup" drops all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables". 55 destroy, //!< The @ref orxonox::MetaPickup "MetaPickup" destroys all the @ref orxonox::PickupCarrier "PickupCarriers'" @ref orxonox::Pickupable "Pickupables". 56 destroyCarrier //!< The @ref orxonox::MetaPickup "MetaPickup" destroys the @ref orxonox::PickupCarrier "PickupCarrier". 57 }; 61 58 62 59 /** … … 100 97 @return Returns an enum with the meta type of the MetaPickup. 101 98 */ 102 inline pickupMetaType::Value getMetaType(void) const99 inline PickupMetaType getMetaType(void) const 103 100 { return this->metaType_; } 104 101 const std::string& getMetaTypeAsString(void) const; //!< Get the meta type of this MetaPickup. … … 109 106 @param type The meta type as an enum. 110 107 */ 111 inline void setMetaType( pickupMetaType::Value type)108 inline void setMetaType(PickupMetaType type) 112 109 { this->metaType_ = type; } 113 110 void setMetaTypeAsString(const std::string& type); //!< Set the meta type of this MetaPickup. … … 116 113 void initialize(void); //!< Initializes the member variables. 117 114 118 pickupMetaType::Value metaType_; //!< The meta type of the MetaPickup, determines which actions are taken.115 PickupMetaType metaType_; //!< The meta type of the MetaPickup, determines which actions are taken. 119 116 120 117 //! Static strings for the meta types.
Note: See TracChangeset
for help on using the changeset viewer.