#include <src/orxonox/objects/pickup/ModifierPickup.h>
Public Member Functions | |
virtual bool | dropped (Pawn *pawn) |
Override of the BaseItem::dropped() method. | |
float | getAdditiveAcceleration () const |
Get the amount of acceleration this pickup adds. | |
float | getAdditiveDamage () const |
Get the amount of damage this pickup adds. | |
float | getDuration () const |
Get the duration of this pickup. | |
virtual int | getMaxCarryAmount () |
Allow the player to carry infinite ModPickups. | |
float | getMultiplicativeAcceleration () const |
Get the factor by which this pickup multiplies the acceleration. | |
float | getMultiplicativeDamage () const |
Get the factor by which this pickup multiplies the damage. | |
ModifierPickup (BaseObject *creator) | |
Constructor. Registers the ModifierPickup. | |
virtual bool | pickedUp (Pawn *pawn) |
Override of the BaseItem::pickedUp() method. | |
void | setAdditiveAcceleration (float value) |
Set the amount of acceleration this pickup adds. | |
void | setAdditiveDamage (float value) |
Set the amount of damage this pickup adds. | |
void | setDuration (float duration) |
Set the duration of this pickup. | |
void | setMultiplicativeAcceleration (float value) |
Set the factor by which this pickup multiplies the acceleration. | |
void | setMultiplicativeDamage (float value) |
Set the factor by which this pickup multiplies the damage. | |
void | timerCallback (Pawn *pawn) |
Method called when the timer runs out. | |
virtual void | XMLPort (Element &xmlelement, XMLPort::Mode mode) |
To create a ModifierPickup through the level file. | |
virtual | ~ModifierPickup () |
Deconstructor. | |
Private Member Functions | |
float | getAdditiveModifier (ModifierType::Value type) const |
Get the additive modifier for a given ModifierType. | |
float | getMultiplicativeModifier (ModifierType::Value type) const |
Get the multiplicative modifier for a given ModifierType. | |
void | setAdditiveModifier (ModifierType::Value type, float value) |
Set the additive modifier for a given ModifierType. | |
void | setMultiplicativeModifier (ModifierType::Value type, float value) |
Set the multiplicative modifier for a given ModifierType. | |
Private Attributes | |
std::map< ModifierType::Value, float > | additiveModifiers_ |
Map of additive modifiers, indexed by ModifierType. | |
float | duration_ |
Duration of this pickup's effect (0 for unlimited). | |
std::map< ModifierType::Value, float > | multiplicativeModifiers_ |
Map of multiplicative modifiers, indexed by ModifierType. | |
Timer< ModifierPickup > | timer_ |
Timer used if the pickup's effect has a time limit. |
orxonox::ModifierPickup::ModifierPickup | ( | BaseObject * | creator | ) |
Constructor. Registers the ModifierPickup.
creator | Pointer to the object which created this item. |
References duration_, and RegisterObject.
orxonox::ModifierPickup::~ModifierPickup | ( | ) | [virtual] |
Deconstructor.
bool orxonox::ModifierPickup::dropped | ( | Pawn * | pawn | ) | [virtual] |
Override of the BaseItem::dropped() method.
Invoked when a pawn drops the pickup.
Removes the modifiers from the pawn if the pickup was successfully removed from it's PickupCollection.
pawn | Pawn which dropped the pickup. |
Reimplemented from orxonox::BaseItem.
References additiveModifiers_, orxonox::Pawn::getPickups(), multiplicativeModifiers_, orxonox::PickupCollection::removeAdditiveModifier(), orxonox::BaseItem::removeFrom(), orxonox::PickupCollection::removeMultiplicativeModifier(), and timer_.
Referenced by timerCallback().
float orxonox::ModifierPickup::getAdditiveAcceleration | ( | ) | const [inline] |
Get the amount of acceleration this pickup adds.
References orxonox::ModifierType::Acceleration.
Referenced by XMLPort().
float orxonox::ModifierPickup::getAdditiveDamage | ( | ) | const [inline] |
Get the amount of damage this pickup adds.
References orxonox::ModifierType::Damage.
Referenced by XMLPort().
float orxonox::ModifierPickup::getAdditiveModifier | ( | ModifierType::Value | type | ) | const [private] |
Get the additive modifier for a given ModifierType.
Gets the additive modifier of a given type.
type | ModifierType for which to return the modifier. |
References additiveModifiers_.
float orxonox::ModifierPickup::getDuration | ( | ) | const [inline] |
Get the duration of this pickup.
Referenced by XMLPort().
virtual int orxonox::ModifierPickup::getMaxCarryAmount | ( | ) | [inline, virtual] |
Allow the player to carry infinite ModPickups.
float orxonox::ModifierPickup::getMultiplicativeAcceleration | ( | ) | const [inline] |
Get the factor by which this pickup multiplies the acceleration.
References orxonox::ModifierType::Acceleration.
Referenced by XMLPort().
float orxonox::ModifierPickup::getMultiplicativeDamage | ( | ) | const [inline] |
Get the factor by which this pickup multiplies the damage.
References orxonox::ModifierType::Damage.
Referenced by XMLPort().
float orxonox::ModifierPickup::getMultiplicativeModifier | ( | ModifierType::Value | type | ) | const [private] |
Get the multiplicative modifier for a given ModifierType.
Gets the multiplicative modifier of a given type.
type | ModifierType for which to return the modifier. |
References multiplicativeModifiers_.
bool orxonox::ModifierPickup::pickedUp | ( | Pawn * | pawn | ) | [virtual] |
Override of the BaseItem::pickedUp() method.
Invoked when a pawn picks up the pickup.
Adds the modifiers to the pawn and sets a timer (if effect is limited) if the pickup could be added to the pawn's PickupCollection.
pawn | Pawn which picked up the pickup. |
Reimplemented from orxonox::BaseItem.
References orxonox::PickupCollection::addAdditiveModifier(), additiveModifiers_, orxonox::PickupCollection::addMultiplicativeModifier(), orxonox::BaseItem::addTo(), orxonox::createExecutor(), duration_, orxonox::Pawn::getPickups(), multiplicativeModifiers_, orxonox::Executor::setDefaultValues(), timer_, and timerCallback().
void orxonox::ModifierPickup::setAdditiveAcceleration | ( | float | value | ) | [inline] |
Set the amount of acceleration this pickup adds.
value | How much acceleration this pickup adds. |
References orxonox::ModifierType::Acceleration.
Referenced by XMLPort().
void orxonox::ModifierPickup::setAdditiveDamage | ( | float | value | ) | [inline] |
Set the amount of damage this pickup adds.
value | How much damage this pickup adds. |
References orxonox::ModifierType::Damage.
Referenced by XMLPort().
void orxonox::ModifierPickup::setAdditiveModifier | ( | ModifierType::Value | type, | |
float | value | |||
) | [private] |
Set the additive modifier for a given ModifierType.
Gets the additive modifier of a given type.
type | ModifierType for which to return the modifier. | |
value | The new additive modifier for type. |
References additiveModifiers_.
void orxonox::ModifierPickup::setDuration | ( | float | duration | ) | [inline] |
Set the duration of this pickup.
duration | How long the effect should hold. |
Referenced by XMLPort().
void orxonox::ModifierPickup::setMultiplicativeAcceleration | ( | float | value | ) | [inline] |
Set the factor by which this pickup multiplies the acceleration.
value | Factor by which to multiply acceleration. |
References orxonox::ModifierType::Acceleration.
Referenced by XMLPort().
void orxonox::ModifierPickup::setMultiplicativeDamage | ( | float | value | ) | [inline] |
Set the factor by which this pickup multiplies the damage.
value | Factor by which to multiply damage. |
References orxonox::ModifierType::Damage.
Referenced by XMLPort().
void orxonox::ModifierPickup::setMultiplicativeModifier | ( | ModifierType::Value | type, | |
float | value | |||
) | [private] |
Set the multiplicative modifier for a given ModifierType.
Gets the multiplicative modifier of a given type.
type | ModifierType for which to return the modifier. | |
value | The new multiplicative modifier for type. |
References multiplicativeModifiers_.
void orxonox::ModifierPickup::timerCallback | ( | Pawn * | pawn | ) |
Method called when the timer runs out.
Invoked when the timer finished, calls dropped().
References COUT, and dropped().
Referenced by pickedUp().
void orxonox::ModifierPickup::XMLPort | ( | Element & | element, | |
XMLPort::Mode | mode | |||
) | [virtual] |
To create a ModifierPickup through the level file.
Method for loading information from a level file.
element | XMLElement from which to read the data. | |
mode | XMLPort mode to use. |
Reimplemented from orxonox::BaseItem.
References getAdditiveAcceleration(), getAdditiveDamage(), getDuration(), getMultiplicativeAcceleration(), getMultiplicativeDamage(), setAdditiveAcceleration(), setAdditiveDamage(), setDuration(), setMultiplicativeAcceleration(), setMultiplicativeDamage(), SUPER, XMLPortParam, and XMLPortParamTemplate.
std::map<ModifierType::Value, float> orxonox::ModifierPickup::additiveModifiers_ [private] |
Map of additive modifiers, indexed by ModifierType.
Referenced by dropped(), getAdditiveModifier(), pickedUp(), and setAdditiveModifier().
float orxonox::ModifierPickup::duration_ [private] |
std::map<ModifierType::Value, float> orxonox::ModifierPickup::multiplicativeModifiers_ [private] |
Map of multiplicative modifiers, indexed by ModifierType.
Referenced by dropped(), getMultiplicativeModifier(), pickedUp(), and setMultiplicativeModifier().
Timer<ModifierPickup> orxonox::ModifierPickup::timer_ [private] |