orxonox::PickupCollection Class Reference

PickupCollection for organising items. More...

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

List of all members.

Public Member Functions

bool add (BaseItem *item)
 Add an item to the collection.
void addAdditiveModifier (ModifierType::Value type, float value)
 Add an additive modifier.
void addMultiplicativeModifier (ModifierType::Value type, float value)
 Add a multiplicative modifier.
bool checkSlot (BaseItem *item)
 Check if there's a free slot in the collection for an item.
void clear ()
 Empty the collection.
bool contains (BaseItem *item, bool anyOfType=false)
 Check if the collection contains an item.
float getAdditiveModifier (ModifierType::Value type)
 Get total additive modifier.
UsableItemgetCurrentUsable ()
std::deque< EquipmentItem * > getEquipmentItems ()
 Get a list of equipment-type items.
std::multimap< std::string,
BaseItem * > 
getItems () const
 Get the map of contained items.
float getMultiplicativeModifier (ModifierType::Value type)
 Get total multiplicative modifier.
PawngetOwner () const
 Get the owner of the PickupCollection.
std::deque< PassiveItem * > getPassiveItems ()
 Get a list of passive items.
std::deque< UsableItem * > getUsableItems ()
 Get a list of usable items.
 PickupCollection ()
 Constructor.
Vector3 processModifiers (ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication=false)
 Apply the modifiers to a Vector3.
float processModifiers (ModifierType::Value type, float inputValue, bool addBeforeMultiplication=false)
 Apply the modifiers to a float.
void remove (BaseItem *item, bool removeAllOfType=false)
 Remove an item from the collection.
void removeAdditiveModifier (ModifierType::Value type, float value)
 Remove an additive modifier.
void removeMultiplicativeModifier (ModifierType::Value type, float value)
 Remove a multiplicative modifier.
void setCurrentUsable (UsableItem *usable)
void setOwner (Pawn *owner)
 Set the owner of the PickupCollection.
void useItem (UsableItem *item)
 Use a usable item.
void useItem ()
 Use the first usable item.

Private Attributes

std::multimap
< ModifierType::Value, float > 
additiveModifiers_
 Contains additive modifiers (indexed by ModifierType).
bool bBlockRemovals_
 Whether to block direct removals through remove().
UsableItemcurrentUsable_
std::multimap< std::string,
BaseItem * > 
items_
 Map of items in the collection (indexed by pickupIdentifier of the items).
std::multimap
< ModifierType::Value, float > 
multiplicativeModifiers_
 Contains multiplicative modifiers (indexed by ModifierType).
Pawnowner_
 The owner of the PickupCollection.


Detailed Description

PickupCollection for organising items.

Author:
Daniel 'Huty' Haggenmueller

Constructor & Destructor Documentation

orxonox::PickupCollection::PickupCollection (  ) 

Constructor.

References bBlockRemovals_, and currentUsable_.


Member Function Documentation

bool orxonox::PickupCollection::add ( BaseItem item  ) 

Add an item to the collection.

Only adds the item if there's a free slot for it.

Parameters:
item Item to add to the collection.
Returns:
Returns whether the item has been added to the collection.

References checkSlot(), Class, currentUsable_, orxonox::BaseItem::getPickupIdentifier(), orxonox::OrxonoxClass::isA(), and items_.

Referenced by orxonox::BaseItem::addTo().

void orxonox::PickupCollection::addAdditiveModifier ( ModifierType::Value  type,
float  value 
)

Add an additive modifier.

Parameters:
type ModifierType to add.
value Value for the modifier.

References additiveModifiers_.

Referenced by orxonox::ModifierPickup::pickedUp().

void orxonox::PickupCollection::addMultiplicativeModifier ( ModifierType::Value  type,
float  value 
)

Add a multiplicative modifier.

Parameters:
type ModifierType to add.
value Value for the modifier.

References multiplicativeModifiers_.

Referenced by orxonox::ModifierPickup::pickedUp().

bool orxonox::PickupCollection::checkSlot ( BaseItem item  ) 

Check if there's a free slot in the collection for an item.

Check if there's a free slot for an item.

Compares the amount of the item-type in the collection against the maximal amount of the item that can be carried.

Parameters:
item Item to check for a slot.
Returns:
Returns if there's a free slot for the item.

References orxonox::BaseItem::getMaxCarryAmount(), orxonox::BaseItem::getPickupIdentifier(), and items_.

Referenced by add().

void orxonox::PickupCollection::clear (  ) 

Empty the collection.

Calls dropped() on all the items in the collection, then clears the collection.

References bBlockRemovals_, currentUsable_, and items_.

Referenced by orxonox::Pawn::dropItems().

bool orxonox::PickupCollection::contains ( BaseItem item,
bool  anyOfType = false 
)

Check if the collection contains an item.

Check if an item/type of item is in the collection.

Parameters:
item Item to check.
anyOfType If it should look for any item of the item's type (default: false).
Returns:
Whether the collection contains the item/type of item.

References orxonox::BaseItem::getPickupIdentifier(), and items_.

Referenced by remove().

float orxonox::PickupCollection::getAdditiveModifier ( ModifierType::Value  type  ) 

Get total additive modifier.

Get the total amount of an additive modifier.

Parameters:
type Type for which to get the total.
Returns:
Returns the sum of the additive modifiers of the type.

References additiveModifiers_.

Referenced by processModifiers().

UsableItem* orxonox::PickupCollection::getCurrentUsable (  )  [inline]

std::deque< EquipmentItem * > orxonox::PickupCollection::getEquipmentItems (  ) 

Get a list of equipment-type items.

Returns:
Returns a list of all the equipment-type items in the collection.

References Class, and items_.

Referenced by orxonox::PickupInventory::getEquipmentCount(), orxonox::PickupInventory::getEquipmentItem(), and orxonox::PickupInventory::updateEquipment().

std::multimap<std::string, BaseItem*> orxonox::PickupCollection::getItems (  )  const [inline]

Get the map of contained items.

Returns:
The map of items.

float orxonox::PickupCollection::getMultiplicativeModifier ( ModifierType::Value  type  ) 

Get total multiplicative modifier.

Get the total amount of a multiplicative modifier.

Parameters:
type Type for which to get the total.
Returns:
Returns the product of the multiplicative modifiers of the type.

References multiplicativeModifiers_.

Referenced by processModifiers().

Pawn* orxonox::PickupCollection::getOwner (  )  const [inline]

Get the owner of the PickupCollection.

Returns:
Returns the pawn which owns the PickupCollection.

std::deque< PassiveItem * > orxonox::PickupCollection::getPassiveItems (  ) 

Get a list of passive items.

Returns:
Returns a list of all the passive items in the collection.

References Class, and items_.

Referenced by orxonox::PickupInventory::getPassiveCount(), and orxonox::PickupInventory::getPassiveItem().

std::deque< UsableItem * > orxonox::PickupCollection::getUsableItems (  ) 

Vector3 orxonox::PickupCollection::processModifiers ( ModifierType::Value  type,
Vector3  inputValue,
bool  addBeforeMultiplication = false 
)

Apply the modifiers to a Vector3.

Applies modifiers to a Vector3.

Parameters:
type Type of modifier tp apply.
inputValue Value which is to be processed.
addBeforeMultiplication Whether to apply the additive modifier before the multiplicative one (default: false).
Returns:
Returns the value after being processed.

References getAdditiveModifier(), getMultiplicativeModifier(), and orxonox::MT_Type::Vector3.

float orxonox::PickupCollection::processModifiers ( ModifierType::Value  type,
float  inputValue,
bool  addBeforeMultiplication = false 
)

Apply the modifiers to a float.

Applies modifiers to a float.

Parameters:
type Type of modifier tp apply.
inputValue Value which is to be processed.
addBeforeMultiplication Whether to apply the additive modifier before the multiplicative one (default: false).
Returns:
Returns the value after being processed.

References getAdditiveModifier(), and getMultiplicativeModifier().

Referenced by orxonox::Projectile::collidesAgainst(), and orxonox::Engine::tick().

void orxonox::PickupCollection::remove ( BaseItem item,
bool  removeAllOfType = false 
)

Remove an item from the collection.

Remove an item/all of a type from the collection.

Parameters:
item Item to remove.
removeAllOfType Whether to remove all the items with the item's type (default: false).

References bBlockRemovals_, contains(), currentUsable_, orxonox::BaseItem::getPickupIdentifier(), getUsableItems(), and items_.

Referenced by orxonox::BaseItem::removeFrom().

void orxonox::PickupCollection::removeAdditiveModifier ( ModifierType::Value  type,
float  value 
)

Remove an additive modifier.

Parameters:
type Type of modifier.
value Value which is to be removed.

References additiveModifiers_.

Referenced by orxonox::ModifierPickup::dropped().

void orxonox::PickupCollection::removeMultiplicativeModifier ( ModifierType::Value  type,
float  value 
)

Remove a multiplicative modifier.

Parameters:
type Type of modifier.
value Value which is to be removed.

References multiplicativeModifiers_.

Referenced by orxonox::ModifierPickup::dropped().

void orxonox::PickupCollection::setCurrentUsable ( UsableItem usable  )  [inline]

void orxonox::PickupCollection::setOwner ( Pawn owner  )  [inline]

Set the owner of the PickupCollection.

Parameters:
owner The new Pawn which owns the PickupCollection.

Referenced by orxonox::Pawn::Pawn().

void orxonox::PickupCollection::useItem ( UsableItem item  ) 

Use a usable item.

Uses a usable item on the owner of the collection.

Parameters:
item Item to use.

References owner_, and orxonox::UsableItem::used().

void orxonox::PickupCollection::useItem (  ) 

Use the first usable item.

Uses the first usable item in the collection on the owner.

References currentUsable_, owner_, and orxonox::UsableItem::used().


Member Data Documentation

Contains additive modifiers (indexed by ModifierType).

Referenced by addAdditiveModifier(), getAdditiveModifier(), and removeAdditiveModifier().

Whether to block direct removals through remove().

Referenced by clear(), PickupCollection(), and remove().

Map of items in the collection (indexed by pickupIdentifier of the items).

Referenced by add(), checkSlot(), clear(), contains(), getEquipmentItems(), getPassiveItems(), getUsableItems(), and remove().

Contains multiplicative modifiers (indexed by ModifierType).

Referenced by addMultiplicativeModifier(), getMultiplicativeModifier(), and removeMultiplicativeModifier().

The owner of the PickupCollection.

Referenced by useItem().


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

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