#include <src/orxonox/objects/pickup/PickupCollection.h>
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. | |
UsableItem * | getCurrentUsable () |
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. | |
Pawn * | getOwner () 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(). | |
UsableItem * | currentUsable_ |
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). | |
Pawn * | owner_ |
The owner of the PickupCollection. |
orxonox::PickupCollection::PickupCollection | ( | ) |
bool orxonox::PickupCollection::add | ( | BaseItem * | item | ) |
Add an item to the collection.
Only adds the item if there's a free slot for it.
item | Item to add 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.
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.
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.
item | Item to check for a slot. |
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.
item | Item to check. | |
anyOfType | If it should look for any item of the item's type (default: false). |
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.
type | Type for which to get the total. |
References additiveModifiers_.
Referenced by processModifiers().
UsableItem* orxonox::PickupCollection::getCurrentUsable | ( | ) | [inline] |
std::deque< EquipmentItem * > orxonox::PickupCollection::getEquipmentItems | ( | ) |
Get a list of equipment-type 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.
float orxonox::PickupCollection::getMultiplicativeModifier | ( | ModifierType::Value | type | ) |
Get total multiplicative modifier.
Get the total amount of a multiplicative modifier.
type | Type for which to get the total. |
References multiplicativeModifiers_.
Referenced by processModifiers().
Pawn* orxonox::PickupCollection::getOwner | ( | ) | const [inline] |
std::deque< PassiveItem * > orxonox::PickupCollection::getPassiveItems | ( | ) |
Get a list of passive items.
Referenced by orxonox::PickupInventory::getPassiveCount(), and orxonox::PickupInventory::getPassiveItem().
std::deque< UsableItem * > orxonox::PickupCollection::getUsableItems | ( | ) |
Get a list of usable items.
Referenced by orxonox::PickupInventory::getCurrentUsableIndex(), orxonox::PickupInventory::getUsableCount(), orxonox::PickupInventory::getUsableItem(), remove(), orxonox::PickupInventory::selectUsable(), and orxonox::PickupInventory::updateUsable().
Vector3 orxonox::PickupCollection::processModifiers | ( | ModifierType::Value | type, | |
Vector3 | inputValue, | |||
bool | addBeforeMultiplication = false | |||
) |
Apply the modifiers to a Vector3.
Applies modifiers to a Vector3.
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). |
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.
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). |
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.
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.
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.
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] |
Referenced by orxonox::PickupInventory::selectUsable().
void orxonox::PickupCollection::setOwner | ( | Pawn * | owner | ) | [inline] |
Set the owner of the PickupCollection.
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.
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().
std::multimap<ModifierType::Value, float> orxonox::PickupCollection::additiveModifiers_ [private] |
Contains additive modifiers (indexed by ModifierType).
Referenced by addAdditiveModifier(), getAdditiveModifier(), and removeAdditiveModifier().
bool orxonox::PickupCollection::bBlockRemovals_ [private] |
Whether to block direct removals through remove().
Referenced by clear(), PickupCollection(), and remove().
Referenced by add(), clear(), PickupCollection(), remove(), and useItem().
std::multimap<std::string, BaseItem*> orxonox::PickupCollection::items_ [private] |
Map of items in the collection (indexed by pickupIdentifier of the items).
Referenced by add(), checkSlot(), clear(), contains(), getEquipmentItems(), getPassiveItems(), getUsableItems(), and remove().
std::multimap<ModifierType::Value, float> orxonox::PickupCollection::multiplicativeModifiers_ [private] |
Contains multiplicative modifiers (indexed by ModifierType).
Referenced by addMultiplicativeModifier(), getMultiplicativeModifier(), and removeMultiplicativeModifier().
Pawn* orxonox::PickupCollection::owner_ [private] |