OpenMW
Classes | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes
MWWorld::InventoryStore Class Reference

#include <inventorystore.hpp>

List of all members.

Classes

struct  EffectParams

Public Member Functions

 InventoryStore ()
 InventoryStore (const InventoryStore &store)
InventoryStoreoperator= (const InventoryStore &store)
virtual ContainerStoreIterator add (const Ptr &itemPtr, const Ptr &actorPtr)
void equip (int slot, const ContainerStoreIterator &iterator, const Ptr &actor)
void setSelectedEnchantItem (const ContainerStoreIterator &iterator)
ContainerStoreIterator getSelectedEnchantItem ()
ContainerStoreIterator getSlot (int slot)
void unequipAll (const MWWorld::Ptr &actor)
 Unequip all currently equipped items.
void autoEquip (const MWWorld::Ptr &actor)
 Auto equip items according to stats and item value.
const MWMechanics::MagicEffectsgetMagicEffects () const
 Return magic effects from worn items.
virtual void flagAsModified ()
virtual bool stacks (const Ptr &ptr1, const Ptr &ptr2)
virtual int remove (const Ptr &item, int count, const Ptr &actor)
ContainerStoreIterator unequipSlot (int slot, const Ptr &actor, bool restack=true)
ContainerStoreIterator unequipItem (const Ptr &item, const Ptr &actor)
void setListener (InventoryStoreListener *listener, const Ptr &actor)
 Set a listener for various events, see InventoryStoreListener.
void visitEffectSources (MWMechanics::EffectSourceVisitor &visitor)
void rechargeItems (float duration)
 Restore charge on enchanted items. Note this should only be done for the player.
void purgeEffect (short effectId)
 Remove a magic effect.

Static Public Attributes

static const int Slot_Helmet = 0
static const int Slot_Cuirass = 1
static const int Slot_Greaves = 2
static const int Slot_LeftPauldron = 3
static const int Slot_RightPauldron = 4
static const int Slot_LeftGauntlet = 5
static const int Slot_RightGauntlet = 6
static const int Slot_Boots = 7
static const int Slot_Shirt = 8
static const int Slot_Pants = 9
static const int Slot_Skirt = 10
static const int Slot_Robe = 11
static const int Slot_LeftRing = 12
static const int Slot_RightRing = 13
static const int Slot_Amulet = 14
static const int Slot_Belt = 15
static const int Slot_CarriedRight = 16
static const int Slot_CarriedLeft = 17
static const int Slot_Ammunition = 18
static const int Slots = 19
static const int Slot_NoSlot = -1

Private Types

typedef std::map< std::string,
std::vector< EffectParams > > 
TEffectMagnitudes
typedef std::vector
< ContainerStoreIterator
TSlots
typedef std::vector< std::pair
< ContainerStoreIterator,
float > > 
TRechargingItems

Private Member Functions

void copySlots (const InventoryStore &store)
void initSlots (TSlots &slots_)
void updateMagicEffects (const Ptr &actor)
void updateRechargingItems ()
void fireEquipmentChangedEvent ()

Private Attributes

MWMechanics::MagicEffects mMagicEffects
InventoryStoreListenermListener
bool mUpdatesEnabled
bool mFirstAutoEquip
TEffectMagnitudes mPermanentMagicEffectMagnitudes
TSlots mSlots
ContainerStoreIterator mSelectedEnchantItem
TRechargingItems mRechargingItems

Member Typedef Documentation

typedef std::map<std::string, std::vector<EffectParams> > MWWorld::InventoryStore::TEffectMagnitudes [private]
typedef std::vector<std::pair<ContainerStoreIterator, float> > MWWorld::InventoryStore::TRechargingItems [private]

Constructor & Destructor Documentation


Member Function Documentation

MWWorld::ContainerStoreIterator MWWorld::InventoryStore::add ( const Ptr itemPtr,
const Ptr actorPtr 
) [virtual]

Add the item pointed to by ptr to this container. (Stacks automatically if needed) Auto-equip items if specific conditions are fulfilled (see the implementation).

Note:
The item pointed to is not required to exist beyond this function call.
Attention:
Do not add items to an existing stack by increasing the count instead of calling this function!
Returns:
if stacking happened, return iterator to the item that was stacked against, otherwise iterator to the newly inserted item.

Reimplemented from MWWorld::ContainerStore.

Auto equip items according to stats and item value.

void MWWorld::InventoryStore::copySlots ( const InventoryStore store) [private]
void MWWorld::InventoryStore::equip ( int  slot,
const ContainerStoreIterator iterator,
const Ptr actor 
)
Note:
iterator can be an end-iterator
Attention:
This function is internal to the world model and should not be called from outside.

Reimplemented from MWWorld::ContainerStore.

Return magic effects from worn items.

Returns:
selected magic item (for using enchantments of type "Cast once" or "Cast when used")
Note:
if no item selected, return end() iterator
void MWWorld::InventoryStore::initSlots ( TSlots slots_) [private]
MWWorld::InventoryStore & MWWorld::InventoryStore::operator= ( const InventoryStore store)
void MWWorld::InventoryStore::purgeEffect ( short  effectId)

Remove a magic effect.

void MWWorld::InventoryStore::rechargeItems ( float  duration)

Restore charge on enchanted items. Note this should only be done for the player.

int MWWorld::InventoryStore::remove ( const Ptr item,
int  count,
const Ptr actor 
) [virtual]

Remove count item(s) designated by item from this inventory.

Returns:
the number of items actually removed

Reimplemented from MWWorld::ContainerStore.

void MWWorld::InventoryStore::setListener ( InventoryStoreListener listener,
const Ptr actor 
)

Set a listener for various events, see InventoryStoreListener.

set the selected magic item (for using enchantments of type "Cast once" or "Cast when used")

Note:
to unset the selected item, call this method with end() iterator
bool MWWorld::InventoryStore::stacks ( const Ptr ptr1,
const Ptr ptr2 
) [virtual]
Returns:
true if the two specified objects can stack with each other

Reimplemented from MWWorld::ContainerStore.

Unequip all currently equipped items.

Unequip an item identified by its Ptr. An exception is thrown if the item is not currently equipped.

Returns:
an iterator to the item that was previously in the slot (it can be re-stacked so its count may be different than when it was equipped).
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot ( int  slot,
const Ptr actor,
bool  restack = true 
)

Unequip slot.

Returns:
an iterator to the item that was previously in the slot (if restack is true, the item can be re-stacked so its count may differ from when it was equipped).
void MWWorld::InventoryStore::updateMagicEffects ( const Ptr actor) [private]

Member Data Documentation

const int MWWorld::InventoryStore::Slot_Amulet = 14 [static]
const int MWWorld::InventoryStore::Slot_Belt = 15 [static]
const int MWWorld::InventoryStore::Slot_Boots = 7 [static]
const int MWWorld::InventoryStore::Slot_Cuirass = 1 [static]
const int MWWorld::InventoryStore::Slot_Greaves = 2 [static]
const int MWWorld::InventoryStore::Slot_Helmet = 0 [static]
const int MWWorld::InventoryStore::Slot_LeftRing = 12 [static]
const int MWWorld::InventoryStore::Slot_NoSlot = -1 [static]
const int MWWorld::InventoryStore::Slot_Pants = 9 [static]
const int MWWorld::InventoryStore::Slot_RightRing = 13 [static]
const int MWWorld::InventoryStore::Slot_Robe = 11 [static]
const int MWWorld::InventoryStore::Slot_Shirt = 8 [static]
const int MWWorld::InventoryStore::Slot_Skirt = 10 [static]
const int MWWorld::InventoryStore::Slots = 19 [static]

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