OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
MWWorld::InventoryStore Class Reference

#include <inventorystore.hpp>

Inheritance diagram for MWWorld::InventoryStore:
Collaboration diagram for MWWorld::InventoryStore:

Classes

struct  EffectParams
 

Public Member Functions

 InventoryStore ()
 
 InventoryStore (const InventoryStore &store)
 
InventoryStoreoperator= (const InventoryStore &store)
 
virtual InventoryStoreclone ()
 
virtual ContainerStoreIterator add (const Ptr &itemPtr, int count, const Ptr &actorPtr, bool setOwner=false)
 
void equip (int slot, const ContainerStoreIterator &iterator, const Ptr &actor)
 
bool isEquipped (const MWWorld::ConstPtr &item)
 Utility function, returns true if the given item is equipped in any slot. More...
 
void setSelectedEnchantItem (const ContainerStoreIterator &iterator)
 
ContainerStoreIterator getSelectedEnchantItem ()
 
ContainerStoreIterator getSlot (int slot)
 
void unequipAll (const MWWorld::Ptr &actor)
 Unequip all currently equipped items. More...
 
void autoEquip (const MWWorld::Ptr &actor)
 Auto equip items according to stats and item value. More...
 
void autoEquipShield (const MWWorld::Ptr &actor)
 Auto-equip the shield with most health. More...
 
const MWMechanics::MagicEffectsgetMagicEffects () const
 Return magic effects from worn items. More...
 
virtual void flagAsModified ()
 
virtual bool stacks (const ConstPtr &ptr1, const ConstPtr &ptr2)
 
virtual int remove (const Ptr &item, int count, const Ptr &actor)
 
ContainerStoreIterator unequipSlot (int slot, const Ptr &actor)
 
ContainerStoreIterator unequipItem (const Ptr &item, const Ptr &actor)
 
ContainerStoreIterator unequipItemQuantity (const Ptr &item, const Ptr &actor, int count)
 
void setInvListener (InventoryStoreListener *listener, const Ptr &actor)
 Set a listener for various events, see InventoryStoreListener. More...
 
InventoryStoreListenergetInvListener ()
 
void visitEffectSources (MWMechanics::EffectSourceVisitor &visitor)
 
void rechargeItems (float duration)
 Restore charge on enchanted items. Note this should only be done for the player. More...
 
void purgeEffect (short effectId)
 Remove a magic effect. More...
 
void purgeEffect (short effectId, const std::string &sourceId)
 Remove a magic effect. More...
 
virtual void clear ()
 Empty container. More...
 
virtual void writeState (ESM::InventoryState &state) const
 
virtual void readState (const ESM::InventoryState &state)
 
- Public Member Functions inherited from MWWorld::ContainerStore
 ContainerStore ()
 
virtual ~ContainerStore ()
 
ContainerStoreIterator begin (int mask=Type_All)
 
ContainerStoreIterator end ()
 
ContainerStoreIterator add (const std::string &id, int count, const Ptr &actorPtr)
 Utility to construct a ManualRef and call add(ptr, count, actorPtr, true) More...
 
int remove (const std::string &itemId, int count, const Ptr &actor)
 
ContainerStoreIterator unstack (const Ptr &ptr, const Ptr &container, int count=1)
 
MWWorld::ContainerStoreIterator restack (const MWWorld::Ptr &item)
 
int count (const std::string &id)
 
ContainerStoreListenergetContListener () const
 
void setContListener (ContainerStoreListener *listener)
 
void fill (const ESM::InventoryList &items, const std::string &owner)
 Insert items into *this. More...
 
void restock (const ESM::InventoryList &items, const MWWorld::Ptr &ptr, const std::string &owner)
 
float getWeight () const
 Return total weight of the items contained in *this. More...
 
Ptr search (const std::string &id)
 
template<typename T >
MWWorld::ContainerStoreIterator getState (CellRefList< T > &collection, const ESM::ObjectState &state)
 

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
 
- Static Public Attributes inherited from MWWorld::ContainerStore
static const int Type_Potion = 0x0001
 
static const int Type_Apparatus = 0x0002
 
static const int Type_Armor = 0x0004
 
static const int Type_Book = 0x0008
 
static const int Type_Clothing = 0x0010
 
static const int Type_Ingredient = 0x0020
 
static const int Type_Light = 0x0040
 
static const int Type_Lockpick = 0x0080
 
static const int Type_Miscellaneous = 0x0100
 
static const int Type_Probe = 0x0200
 
static const int Type_Repair = 0x0400
 
static const int Type_Weapon = 0x0800
 
static const int Type_Last = Type_Weapon
 
static const int Type_All = 0xffff
 
static const std::string sGoldId = "gold_001"
 

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 (const Ptr &actor)
 
virtual void storeEquipmentState (const MWWorld::LiveCellRefBase &ref, int index, ESM::InventoryState &inventory) const
 
virtual void readEquipmentState (const MWWorld::ContainerStoreIterator &iter, int index, const ESM::InventoryState &inventory)
 
bool canActorAutoEquip (const MWWorld::Ptr &actor, const MWWorld::Ptr &item)
 

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from MWWorld::ContainerStore
static int getType (const ConstPtr &ptr)
 
- Protected Member Functions inherited from MWWorld::ContainerStore
ContainerStoreIterator addNewStack (const ConstPtr &ptr, int count)
 Add the item to this container (do not try to stack it onto existing items) More...
 

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

MWWorld::InventoryStore::InventoryStore ( )

Here is the call graph for this function:

Here is the caller graph for this function:

MWWorld::InventoryStore::InventoryStore ( const InventoryStore store)

Here is the call graph for this function:

Member Function Documentation

MWWorld::ContainerStoreIterator MWWorld::InventoryStore::add ( const Ptr itemPtr,
int  count,
const Ptr actorPtr,
bool  setOwner = false 
)
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!
Parameters
setOwnerSet the owner of the added item to actorPtr?
Returns
if stacking happened, return iterator to the item that was stacked against, otherwise iterator to the newly inserted item.

Reimplemented from MWWorld::ContainerStore.

Here is the call graph for this function:

void MWWorld::InventoryStore::autoEquip ( const MWWorld::Ptr actor)

Auto equip items according to stats and item value.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWWorld::InventoryStore::autoEquipShield ( const MWWorld::Ptr actor)

Auto-equip the shield with most health.

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWWorld::InventoryStore::canActorAutoEquip ( const MWWorld::Ptr actor,
const MWWorld::Ptr item 
)
private

Here is the call graph for this function:

void MWWorld::InventoryStore::clear ( )
virtual

Empty container.

Reimplemented from MWWorld::ContainerStore.

Here is the call graph for this function:

virtual InventoryStore* MWWorld::InventoryStore::clone ( )
inlinevirtual

Reimplemented from MWWorld::ContainerStore.

Here is the call graph for this function:

void MWWorld::InventoryStore::copySlots ( const InventoryStore store)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWWorld::InventoryStore::equip ( int  slot,
const ContainerStoreIterator iterator,
const Ptr actor 
)
Warning
iterator can not be an end()-iterator, use unequip function instead

Here is the call graph for this function:

Here is the caller graph for this function:

void MWWorld::InventoryStore::fireEquipmentChangedEvent ( const Ptr actor)
private
void MWWorld::InventoryStore::flagAsModified ( )
virtual
Attention
This function is internal to the world model and should not be called from outside.

Reimplemented from MWWorld::ContainerStore.

Here is the call graph for this function:

MWWorld::InventoryStoreListener * MWWorld::InventoryStore::getInvListener ( )

Here is the caller graph for this function:

const MWMechanics::MagicEffects & MWWorld::InventoryStore::getMagicEffects ( ) const

Return magic effects from worn items.

Here is the caller graph for this function:

MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSelectedEnchantItem ( )
Returns
selected magic item (for using enchantments of type "Cast once" or "Cast when used")
Note
if no item selected, return end() iterator

Here is the caller graph for this function:

MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot ( int  slot)

Here is the caller graph for this function:

void MWWorld::InventoryStore::initSlots ( TSlots slots_)
private

Here is the caller graph for this function:

bool MWWorld::InventoryStore::isEquipped ( const MWWorld::ConstPtr item)

Utility function, returns true if the given item is equipped in any slot.

Here is the caller graph for this function:

MWWorld::InventoryStore & MWWorld::InventoryStore::operator= ( const InventoryStore store)
void MWWorld::InventoryStore::purgeEffect ( short  effectId)

Remove a magic effect.

Here is the caller graph for this function:

void MWWorld::InventoryStore::purgeEffect ( short  effectId,
const std::string &  sourceId 
)

Remove a magic effect.

Here is the call graph for this function:

void MWWorld::InventoryStore::readEquipmentState ( const MWWorld::ContainerStoreIterator iter,
int  index,
const ESM::InventoryState inventory 
)
privatevirtual

Reimplemented from MWWorld::ContainerStore.

Here is the call graph for this function:

void MWWorld::InventoryStore::readState ( const ESM::InventoryState state)
virtual

Reimplemented from MWWorld::ContainerStore.

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Set a listener for various events, see InventoryStoreListener.

Here is the caller graph for this function:

void MWWorld::InventoryStore::setSelectedEnchantItem ( const ContainerStoreIterator iterator)

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

Here is the caller graph for this function:

bool MWWorld::InventoryStore::stacks ( const ConstPtr ptr1,
const ConstPtr ptr2 
)
virtual
Returns
true if the two specified objects can stack with each other

Reimplemented from MWWorld::ContainerStore.

Here is the call graph for this function:

void MWWorld::InventoryStore::storeEquipmentState ( const MWWorld::LiveCellRefBase ref,
int  index,
ESM::InventoryState inventory 
) const
privatevirtual

Reimplemented from MWWorld::ContainerStore.

void MWWorld::InventoryStore::unequipAll ( const MWWorld::Ptr actor)

Unequip all currently equipped items.

Here is the caller graph for this function:

MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipItem ( const Ptr item,
const Ptr actor 
)

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).

Here is the caller graph for this function:

MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipItemQuantity ( const Ptr item,
const Ptr actor,
int  count 
)

Unequip a specific quantity of an item identified by its Ptr. An exception is thrown if the item is not currently equipped, if count <= 0, or if count > the item stack size.

Returns
an iterator to the unequipped items that were previously in the slot (they can be re-stacked so its count may be different than the requested count).

Here is the call graph for this function:

Here is the caller graph for this function:

MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot ( int  slot,
const Ptr actor 
)

Unequip slot.

Returns
an iterator to the item that was previously in the slot

Here is the call graph for this function:

Here is the caller graph for this function:

void MWWorld::InventoryStore::updateMagicEffects ( const Ptr actor)
private

Here is the call graph for this function:

void MWWorld::InventoryStore::updateRechargingItems ( )
private

Here is the call graph for this function:

void MWWorld::InventoryStore::visitEffectSources ( MWMechanics::EffectSourceVisitor visitor)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWWorld::InventoryStore::writeState ( ESM::InventoryState state) const
virtual

Reimplemented from MWWorld::ContainerStore.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

bool MWWorld::InventoryStore::mFirstAutoEquip
private
InventoryStoreListener* MWWorld::InventoryStore::mListener
private
MWMechanics::MagicEffects MWWorld::InventoryStore::mMagicEffects
private
TEffectMagnitudes MWWorld::InventoryStore::mPermanentMagicEffectMagnitudes
private
TRechargingItems MWWorld::InventoryStore::mRechargingItems
private
bool MWWorld::InventoryStore::mRechargingItemsUpToDate
private
ContainerStoreIterator MWWorld::InventoryStore::mSelectedEnchantItem
private
TSlots MWWorld::InventoryStore::mSlots
private
bool MWWorld::InventoryStore::mUpdatesEnabled
private
const int MWWorld::InventoryStore::Slot_Ammunition = 18
static
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_CarriedLeft = 17
static
const int MWWorld::InventoryStore::Slot_CarriedRight = 16
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_LeftGauntlet = 5
static
const int MWWorld::InventoryStore::Slot_LeftPauldron = 3
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_RightGauntlet = 6
static
const int MWWorld::InventoryStore::Slot_RightPauldron = 4
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: