Changeset 3257 for code/branches/core4/src/orxonox/objects/pickup
- Timestamp:
- Jun 30, 2009, 3:14:45 PM (16 years ago)
- Location:
- code/branches/core4/src/orxonox/objects/pickup
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/orxonox/objects/pickup/ModifierPickup.cc
r3196 r3257 87 87 if (this->addTo(pawn)) 88 88 { 89 std::map<ModifierType:: Enum, float>::iterator it;89 std::map<ModifierType::Value, float>::iterator it; 90 90 91 91 for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++) … … 124 124 if (this->removeFrom(pawn)) 125 125 { 126 std::map<ModifierType:: Enum, float>::iterator it;126 std::map<ModifierType::Value, float>::iterator it; 127 127 128 128 for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++) … … 158 158 @return Returns the additive modifier for type (or 0 if not exists). 159 159 */ 160 float ModifierPickup::getAdditiveModifier(ModifierType:: Enumtype) const161 { 162 std::map<ModifierType:: Enum, float>::const_iterator it = this->additiveModifiers_.find(type);160 float ModifierPickup::getAdditiveModifier(ModifierType::Value type) const 161 { 162 std::map<ModifierType::Value, float>::const_iterator it = this->additiveModifiers_.find(type); 163 163 if (it != this->additiveModifiers_.end()) 164 164 return (*it).second; … … 171 171 @return Returns the multiplicative modifier for type (or 1 if not exists). 172 172 */ 173 float ModifierPickup::getMultiplicativeModifier(ModifierType:: Enumtype) const174 { 175 std::map<ModifierType:: Enum, float>::const_iterator it = this->multiplicativeModifiers_.find(type);173 float ModifierPickup::getMultiplicativeModifier(ModifierType::Value type) const 174 { 175 std::map<ModifierType::Value, float>::const_iterator it = this->multiplicativeModifiers_.find(type); 176 176 if (it != this->multiplicativeModifiers_.end()) 177 177 return (*it).second; … … 184 184 @param value The new additive modifier for type. 185 185 */ 186 void ModifierPickup::setAdditiveModifier(ModifierType:: Enumtype, float value)186 void ModifierPickup::setAdditiveModifier(ModifierType::Value type, float value) 187 187 { 188 188 if (this->additiveModifiers_.find(type) == this->additiveModifiers_.end()) 189 this->additiveModifiers_.insert( std::pair<ModifierType:: Enum, float>(type, value) );189 this->additiveModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) ); 190 190 else 191 191 this->additiveModifiers_[type] = value; … … 196 196 @param value The new multiplicative modifier for type. 197 197 */ 198 void ModifierPickup::setMultiplicativeModifier(ModifierType:: Enumtype, float value)198 void ModifierPickup::setMultiplicativeModifier(ModifierType::Value type, float value) 199 199 { 200 200 if (this->multiplicativeModifiers_.find(type) == this->multiplicativeModifiers_.end()) 201 this->multiplicativeModifiers_.insert( std::pair<ModifierType:: Enum, float>(type, value) );201 this->multiplicativeModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) ); 202 202 else 203 203 this->multiplicativeModifiers_[type] = value; -
code/branches/core4/src/orxonox/objects/pickup/ModifierPickup.h
r3196 r3257 130 130 void timerCallback(Pawn* pawn); //!< Method called when the timer runs out. 131 131 private: 132 float getAdditiveModifier(ModifierType:: Enumtype) const; //!< Get the additive modifier for a given ModifierType.133 float getMultiplicativeModifier(ModifierType:: Enumtype) const; //!< Get the multiplicative modifier for a given ModifierType.134 void setAdditiveModifier(ModifierType:: Enumtype, float value); //!< Set the additive modifier for a given ModifierType.135 void setMultiplicativeModifier(ModifierType:: Enumtype, float value); //!< Set the multiplicative modifier for a given ModifierType132 float getAdditiveModifier(ModifierType::Value type) const; //!< Get the additive modifier for a given ModifierType. 133 float getMultiplicativeModifier(ModifierType::Value type) const; //!< Get the multiplicative modifier for a given ModifierType. 134 void setAdditiveModifier(ModifierType::Value type, float value); //!< Set the additive modifier for a given ModifierType. 135 void setMultiplicativeModifier(ModifierType::Value type, float value); //!< Set the multiplicative modifier for a given ModifierType 136 136 137 std::map<ModifierType:: Enum, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType.138 std::map<ModifierType:: Enum, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType.137 std::map<ModifierType::Value, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType. 138 std::map<ModifierType::Value, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType. 139 139 140 140 float duration_; //!< Duration of this pickup's effect (0 for unlimited). -
code/branches/core4/src/orxonox/objects/pickup/ModifierType.h
r3196 r3257 44 44 @brief Gives the available types for modifiers. 45 45 */ 46 enum Enum46 enum Value 47 47 { 48 48 Unknown = 0, -
code/branches/core4/src/orxonox/objects/pickup/PickupCollection.cc
r3239 r3257 42 42 { 43 43 typedef std::pair<std::multimap<std::string, BaseItem*>::iterator, std::multimap<std::string, BaseItem*>::iterator> item_range; 44 typedef std::pair<std::multimap<ModifierType:: Enum, float>::iterator, std::multimap<ModifierType::Enum, float>::iterator> modifier_range;44 typedef std::pair<std::multimap<ModifierType::Value, float>::iterator, std::multimap<ModifierType::Value, float>::iterator> modifier_range; 45 45 46 46 //! Constructor … … 200 200 @param value Value for the modifier. 201 201 */ 202 void PickupCollection::addAdditiveModifier(ModifierType:: Enumtype, float value)203 { 204 this->additiveModifiers_.insert( std::pair<ModifierType:: Enum, float>(type, value) );202 void PickupCollection::addAdditiveModifier(ModifierType::Value type, float value) 203 { 204 this->additiveModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) ); 205 205 } 206 206 /** … … 209 209 @return Returns the sum of the additive modifiers of the type. 210 210 */ 211 float PickupCollection::getAdditiveModifier(ModifierType:: Enumtype)211 float PickupCollection::getAdditiveModifier(ModifierType::Value type) 212 212 { 213 213 float v = 0.0f; … … 215 215 modifier_range range = this->additiveModifiers_.equal_range(type); 216 216 217 for (std::multimap<ModifierType:: Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)217 for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++) 218 218 { 219 219 v += (*it).second; … … 227 227 @param value Value which is to be removed. 228 228 */ 229 void PickupCollection::removeAdditiveModifier(ModifierType:: Enumtype, float value)229 void PickupCollection::removeAdditiveModifier(ModifierType::Value type, float value) 230 230 { 231 231 modifier_range range = this->additiveModifiers_.equal_range(type); 232 for (std::multimap<ModifierType:: Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)232 for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++) 233 233 { 234 234 if ((*it).second == value) … … 244 244 @param value Value for the modifier. 245 245 */ 246 void PickupCollection::addMultiplicativeModifier(ModifierType:: Enumtype, float value)247 { 248 this->multiplicativeModifiers_.insert( std::pair<ModifierType:: Enum, float>(type, value) );246 void PickupCollection::addMultiplicativeModifier(ModifierType::Value type, float value) 247 { 248 this->multiplicativeModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) ); 249 249 } 250 250 /** … … 253 253 @return Returns the product of the multiplicative modifiers of the type. 254 254 */ 255 float PickupCollection::getMultiplicativeModifier(ModifierType:: Enumtype)255 float PickupCollection::getMultiplicativeModifier(ModifierType::Value type) 256 256 { 257 257 float v = 1.0f; 258 258 259 259 modifier_range range = this->multiplicativeModifiers_.equal_range(type); 260 for (std::multimap<ModifierType:: Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)260 for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++) 261 261 { 262 262 v *= (*it).second; … … 270 270 @param value Value which is to be removed. 271 271 */ 272 void PickupCollection::removeMultiplicativeModifier(ModifierType:: Enumtype, float value)272 void PickupCollection::removeMultiplicativeModifier(ModifierType::Value type, float value) 273 273 { 274 274 modifier_range range = this->multiplicativeModifiers_.equal_range(type); 275 for (std::multimap<ModifierType:: Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)275 for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++) 276 276 { 277 277 if ((*it).second == value) … … 289 289 @return Returns the value after being processed. 290 290 */ 291 float PickupCollection::processModifiers(ModifierType:: Enumtype, float inputValue, bool addBeforeMultiplication)291 float PickupCollection::processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication) 292 292 { 293 293 float outputValue = inputValue; … … 310 310 @return Returns the value after being processed. 311 311 */ 312 Vector3 PickupCollection::processModifiers(ModifierType:: Enumtype, Vector3 inputValue, bool addBeforeMultiplication)312 Vector3 PickupCollection::processModifiers(ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication) 313 313 { 314 314 Vector3 outputValue = inputValue; -
code/branches/core4/src/orxonox/objects/pickup/PickupCollection.h
r3196 r3257 67 67 void useItem(UsableItem* item); //!< Use a usable item. 68 68 69 void addAdditiveModifier(ModifierType:: Enumtype, float value); //!< Add an additive modifier.70 void addMultiplicativeModifier(ModifierType:: Enumtype, float value); //!< Add a multiplicative modifier.69 void addAdditiveModifier(ModifierType::Value type, float value); //!< Add an additive modifier. 70 void addMultiplicativeModifier(ModifierType::Value type, float value); //!< Add a multiplicative modifier. 71 71 72 float getAdditiveModifier(ModifierType:: Enumtype); //!< Get total additive modifier.73 float getMultiplicativeModifier(ModifierType:: Enumtype); //!< Get total multiplicative modifier.72 float getAdditiveModifier(ModifierType::Value type); //!< Get total additive modifier. 73 float getMultiplicativeModifier(ModifierType::Value type); //!< Get total multiplicative modifier. 74 74 75 void removeAdditiveModifier(ModifierType:: Enumtype, float value); //!< Remove an additive modifier.76 void removeMultiplicativeModifier(ModifierType:: Enumtype, float value); //!< Remove a multiplicative modifier.75 void removeAdditiveModifier(ModifierType::Value type, float value); //!< Remove an additive modifier. 76 void removeMultiplicativeModifier(ModifierType::Value type, float value); //!< Remove a multiplicative modifier. 77 77 78 float processModifiers(ModifierType:: Enumtype, float inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a float.79 Vector3 processModifiers(ModifierType:: Enumtype, Vector3 inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a Vector3.78 float processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a float. 79 Vector3 processModifiers(ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a Vector3. 80 80 81 81 /** … … 113 113 bool bBlockRemovals_; //!< Whether to block direct removals through remove(). 114 114 115 std::multimap<ModifierType:: Enum, float> additiveModifiers_; //!< Contains additive modifiers (indexed by ModifierType).116 std::multimap<ModifierType:: Enum, float> multiplicativeModifiers_; //!< Contains multiplicative modifiers (indexed by ModifierType).115 std::multimap<ModifierType::Value, float> additiveModifiers_; //!< Contains additive modifiers (indexed by ModifierType). 116 std::multimap<ModifierType::Value, float> multiplicativeModifiers_; //!< Contains multiplicative modifiers (indexed by ModifierType). 117 117 118 118 std::multimap<std::string, BaseItem*> items_; //!< Map of items in the collection (indexed by pickupIdentifier of the items).
Note: See TracChangeset
for help on using the changeset viewer.