orxonox::ModifierPickup Class Reference

Class for a (temporary) modifier effect. More...

#include <src/orxonox/objects/pickup/ModifierPickup.h>

Inheritance diagram for orxonox::ModifierPickup:

orxonox::PassiveItem orxonox::BaseItem orxonox::BaseObject orxonox::OrxonoxClass

List of all members.

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< ModifierPickuptimer_
 Timer used if the pickup's effect has a time limit.


Detailed Description

Class for a (temporary) modifier effect.

Author:
Daniel 'Huty' Haggenmueller

Constructor & Destructor Documentation

orxonox::ModifierPickup::ModifierPickup ( BaseObject creator  ) 

Constructor. Registers the ModifierPickup.

Parameters:
creator Pointer to the object which created this item.

References duration_, and RegisterObject.

orxonox::ModifierPickup::~ModifierPickup (  )  [virtual]

Deconstructor.


Member Function Documentation

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.

Parameters:
pawn Pawn which dropped the pickup.
Returns:
Returns whether the pickup could be removed.

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.

Returns:
Returns how much 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.

Returns:
Returns how much 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.

Parameters:
type ModifierType for which to return the modifier.
Returns:
Returns the additive modifier for type (or 0 if not exists).

References additiveModifiers_.

float orxonox::ModifierPickup::getDuration (  )  const [inline]

Get the duration of this pickup.

Returns:
Returns how long the effect holds on.

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.

Returns:
Returns the factor by which to multiply acceleration.

References orxonox::ModifierType::Acceleration.

Referenced by XMLPort().

float orxonox::ModifierPickup::getMultiplicativeDamage (  )  const [inline]

Get the factor by which this pickup multiplies the damage.

Returns:
Returns the factor by which to multiply 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.

Parameters:
type ModifierType for which to return the modifier.
Returns:
Returns the multiplicative modifier for type (or 1 if not exists).

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.

Parameters:
pawn Pawn which picked up the pickup.
Returns:
Returns whether the pickup was able to be added to the pawn.

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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.


Member Data Documentation

Map of additive modifiers, indexed by ModifierType.

Referenced by dropped(), getAdditiveModifier(), pickedUp(), and setAdditiveModifier().

Duration of this pickup's effect (0 for unlimited).

Referenced by ModifierPickup(), and pickedUp().

Map of multiplicative modifiers, indexed by ModifierType.

Referenced by dropped(), getMultiplicativeModifier(), pickedUp(), and setMultiplicativeModifier().

Timer used if the pickup's effect has a time limit.

Referenced by dropped(), and pickedUp().


The documentation for this class was generated from the following files:

Generated on Tue Jul 28 16:22:44 2009 for Orxonox by  doxygen 1.5.6