Barotrauma Client
Loading...
Searching...
No Matches
Barotrauma.Inventory Class Reference
Inheritance diagram for Barotrauma.Inventory:
Barotrauma.CharacterInventory Barotrauma.ItemInventory

Classes

class  ItemSlot
 

Public Member Functions

 Inventory (Entity owner, int capacity, int slotsPerRow=5)
 
bool Contains (Item item)
 Is the item contained in this inventory. Does not recursively check items inside items.
 
Item FirstOrDefault ()
 Return the first item in the inventory, or null if the inventory is empty.
 
Item LastOrDefault ()
 Return the last item in the inventory, or null if the inventory is empty.
 
Item GetItemAt (int index)
 Get the item stored in the specified inventory slot. If the slot contains a stack of items, returns the first item in the stack.
 
IEnumerable< ItemGetItemsAt (int index)
 Get all the item stored in the specified inventory slot. Can return more than one item if the slot contains a stack of items.
 
int GetItemStackSlotIndex (Item item, int index)
 
int FindIndex (Item item)
 Find the index of the first slot the item is contained in.
 
List< int > FindIndices (Item item)
 Find the indices of all the slots the item is contained in (two-hand items for example can be in multiple slots). Note that this method instantiates a new list.
 
virtual bool ItemOwnsSelf (Item item)
 Returns true if the item owns any of the parent inventories.
 
virtual int FindAllowedSlot (Item item, bool ignoreCondition=false)
 
bool CanBePut (Item item)
 Can the item be put in the inventory (i.e. is there a suitable free slot or a stack the item can be put in).
 
virtual bool CanBePutInSlot (Item item, int i, bool ignoreCondition=false)
 Can the item be put in the specified slot.
 
bool CanBePut (ItemPrefab itemPrefab, float? condition=null, int? quality=null)
 
virtual bool CanBePutInSlot (ItemPrefab itemPrefab, int i, float? condition=null, int? quality=null)
 
int HowManyCanBePut (ItemPrefab itemPrefab, float? condition=null)
 
virtual int HowManyCanBePut (ItemPrefab itemPrefab, int i, float? condition, bool ignoreItemsInSlot=false)
 
virtual bool TryPutItem (Item item, Character user, IEnumerable< InvSlotType > allowedSlots=null, bool createNetworkEvent=true, bool ignoreCondition=false)
 If there is room, puts the item in the inventory and returns true, otherwise returns false.
 
virtual bool TryPutItem (Item item, int i, bool allowSwapping, bool allowCombine, Character user, bool createNetworkEvent=true, bool ignoreCondition=false)
 
bool IsEmpty ()
 
virtual bool IsFull (bool takeStacksIntoAccount=false)
 Is there room to put more items in the inventory. Doesn't take stacking into account by default.
 
void CreateNetworkEvent ()
 
Item FindItem (Func< Item, bool > predicate, bool recursive)
 
List< ItemFindAllItems (Func< Item, bool > predicate=null, bool recursive=false, List< Item > list=null)
 
Item FindItemByTag (Identifier tag, bool recursive=false)
 
Item FindItemByIdentifier (Identifier identifier, bool recursive=false)
 
virtual void RemoveItem (Item item)
 
void ForceToSlot (Item item, int index)
 Forces an item to a specific slot. Doesn't remove the item from existing slots/inventories or do any other sanity checks, use with caution!
 
void ForceRemoveFromSlot (Item item, int index)
 Removes an item from a specific slot. Doesn't do any sanity checks, use with caution!
 
bool IsInSlot (Item item, int index)
 
void SharedRead (IReadMessage msg, List< ushort >[] receivedItemIds, out bool readyToApply)
 
void SharedWrite (IWriteMessage msg, Range slotRange)
 
void DeleteAllItems ()
 Deletes all items inside the inventory (and also recursively all items inside the items)
 

Public Attributes

readonly Entity Owner
 
bool Locked
 
bool AllowSwappingContainedItems = true
 

Static Public Attributes

const int MaxPossibleStackSize = (1 << 6) - 1
 
const int MaxItemsPerNetworkEvent = 128
 

Protected Member Functions

IEnumerable< ItemGetAllItems (bool checkForDuplicates)
 
virtual void PutItem (Item item, int i, Character user, bool removeItem=true, bool createNetworkEvent=true)
 
bool TrySwapping (int index, Item item, Character user, bool createNetworkEvent, bool swapWholeStack)
 
virtual void CreateNetworkEvent (Range slotRange)
 

Protected Attributes

readonly int capacity
 Capacity, or the number of slots in the inventory.
 
readonly ItemSlot[] slots
 
float syncItemsDelay
 

Properties

int ExtraStackSize [get, set]
 
virtual IEnumerable< ItemAllItems [get]
 All items contained in the inventory. Stacked items are returned as individual instances. DO NOT modify the contents of the inventory while enumerating this list.
 
IEnumerable< ItemAllItemsMod [get]
 All items contained in the inventory. Allows modifying the contents of the inventory while being enumerated.
 
int Capacity [get]
 
static bool IsDragAndDropGiveAllowed [get]
 
int EmptySlotCount [get]
 

Constructor & Destructor Documentation

◆ Inventory()

Barotrauma.Inventory.Inventory ( Entity owner,
int capacity,
int slotsPerRow = 5 )

Member Function Documentation

◆ CanBePut() [1/2]

bool Barotrauma.Inventory.CanBePut ( Item item)

Can the item be put in the inventory (i.e. is there a suitable free slot or a stack the item can be put in).

◆ CanBePut() [2/2]

bool Barotrauma.Inventory.CanBePut ( ItemPrefab itemPrefab,
float? condition = null,
int? quality = null )

◆ CanBePutInSlot() [1/2]

virtual bool Barotrauma.Inventory.CanBePutInSlot ( Item item,
int i,
bool ignoreCondition = false )
virtual

Can the item be put in the specified slot.

Reimplemented in Barotrauma.CharacterInventory, and Barotrauma.ItemInventory.

◆ CanBePutInSlot() [2/2]

virtual bool Barotrauma.Inventory.CanBePutInSlot ( ItemPrefab itemPrefab,
int i,
float? condition = null,
int? quality = null )
virtual

◆ Contains()

bool Barotrauma.Inventory.Contains ( Item item)

Is the item contained in this inventory. Does not recursively check items inside items.

◆ CreateNetworkEvent() [1/2]

void Barotrauma.Inventory.CreateNetworkEvent ( )

◆ CreateNetworkEvent() [2/2]

virtual void Barotrauma.Inventory.CreateNetworkEvent ( Range slotRange)
protectedvirtual

◆ DeleteAllItems()

void Barotrauma.Inventory.DeleteAllItems ( )

Deletes all items inside the inventory (and also recursively all items inside the items)

◆ FindAllItems()

List< Item > Barotrauma.Inventory.FindAllItems ( Func< Item, bool > predicate = null,
bool recursive = false,
List< Item > list = null )

◆ FindAllowedSlot()

virtual int Barotrauma.Inventory.FindAllowedSlot ( Item item,
bool ignoreCondition = false )
virtual

Reimplemented in Barotrauma.ItemInventory.

◆ FindIndex()

int Barotrauma.Inventory.FindIndex ( Item item)

Find the index of the first slot the item is contained in.

◆ FindIndices()

List< int > Barotrauma.Inventory.FindIndices ( Item item)

Find the indices of all the slots the item is contained in (two-hand items for example can be in multiple slots). Note that this method instantiates a new list.

◆ FindItem()

Item Barotrauma.Inventory.FindItem ( Func< Item, bool > predicate,
bool recursive )

◆ FindItemByIdentifier()

Item Barotrauma.Inventory.FindItemByIdentifier ( Identifier identifier,
bool recursive = false )

◆ FindItemByTag()

Item Barotrauma.Inventory.FindItemByTag ( Identifier tag,
bool recursive = false )

◆ FirstOrDefault()

Item Barotrauma.Inventory.FirstOrDefault ( )

Return the first item in the inventory, or null if the inventory is empty.

◆ ForceRemoveFromSlot()

void Barotrauma.Inventory.ForceRemoveFromSlot ( Item item,
int index )

Removes an item from a specific slot. Doesn't do any sanity checks, use with caution!

◆ ForceToSlot()

void Barotrauma.Inventory.ForceToSlot ( Item item,
int index )

Forces an item to a specific slot. Doesn't remove the item from existing slots/inventories or do any other sanity checks, use with caution!

◆ GetAllItems()

IEnumerable< Item > Barotrauma.Inventory.GetAllItems ( bool checkForDuplicates)
protected

◆ GetItemAt()

Item Barotrauma.Inventory.GetItemAt ( int index)

Get the item stored in the specified inventory slot. If the slot contains a stack of items, returns the first item in the stack.

◆ GetItemsAt()

IEnumerable< Item > Barotrauma.Inventory.GetItemsAt ( int index)

Get all the item stored in the specified inventory slot. Can return more than one item if the slot contains a stack of items.

◆ GetItemStackSlotIndex()

int Barotrauma.Inventory.GetItemStackSlotIndex ( Item item,
int index )

◆ HowManyCanBePut() [1/2]

int Barotrauma.Inventory.HowManyCanBePut ( ItemPrefab itemPrefab,
float? condition = null )

◆ HowManyCanBePut() [2/2]

virtual int Barotrauma.Inventory.HowManyCanBePut ( ItemPrefab itemPrefab,
int i,
float? condition,
bool ignoreItemsInSlot = false )
virtual

Reimplemented in Barotrauma.ItemInventory.

◆ IsEmpty()

bool Barotrauma.Inventory.IsEmpty ( )

◆ IsFull()

virtual bool Barotrauma.Inventory.IsFull ( bool takeStacksIntoAccount = false)
virtual

Is there room to put more items in the inventory. Doesn't take stacking into account by default.

Parameters
takeStacksIntoAccountIf true, the inventory is not considered full if all the stacks are not full.

Reimplemented in Barotrauma.ItemInventory.

◆ IsInSlot()

bool Barotrauma.Inventory.IsInSlot ( Item item,
int index )

◆ ItemOwnsSelf()

virtual bool Barotrauma.Inventory.ItemOwnsSelf ( Item item)
virtual

Returns true if the item owns any of the parent inventories.

◆ LastOrDefault()

Item Barotrauma.Inventory.LastOrDefault ( )

Return the last item in the inventory, or null if the inventory is empty.

◆ PutItem()

virtual void Barotrauma.Inventory.PutItem ( Item item,
int i,
Character user,
bool removeItem = true,
bool createNetworkEvent = true )
protectedvirtual

Reimplemented in Barotrauma.CharacterInventory.

◆ RemoveItem()

virtual void Barotrauma.Inventory.RemoveItem ( Item item)
virtual

◆ SharedRead()

void Barotrauma.Inventory.SharedRead ( IReadMessage msg,
List< ushort >[] receivedItemIds,
out bool readyToApply )

◆ SharedWrite()

void Barotrauma.Inventory.SharedWrite ( IWriteMessage msg,
Range slotRange )

◆ TryPutItem() [1/2]

virtual bool Barotrauma.Inventory.TryPutItem ( Item item,
Character user,
IEnumerable< InvSlotType > allowedSlots = null,
bool createNetworkEvent = true,
bool ignoreCondition = false )
virtual

If there is room, puts the item in the inventory and returns true, otherwise returns false.

Reimplemented in Barotrauma.CharacterInventory, and Barotrauma.ItemInventory.

◆ TryPutItem() [2/2]

virtual bool Barotrauma.Inventory.TryPutItem ( Item item,
int i,
bool allowSwapping,
bool allowCombine,
Character user,
bool createNetworkEvent = true,
bool ignoreCondition = false )
virtual

◆ TrySwapping()

bool Barotrauma.Inventory.TrySwapping ( int index,
Item item,
Character user,
bool createNetworkEvent,
bool swapWholeStack )
protected

Member Data Documentation

◆ AllowSwappingContainedItems

bool Barotrauma.Inventory.AllowSwappingContainedItems = true

◆ capacity

readonly int Barotrauma.Inventory.capacity
protected

Capacity, or the number of slots in the inventory.

◆ Locked

bool Barotrauma.Inventory.Locked

◆ MaxItemsPerNetworkEvent

const int Barotrauma.Inventory.MaxItemsPerNetworkEvent = 128
static

◆ MaxPossibleStackSize

const int Barotrauma.Inventory.MaxPossibleStackSize = (1 << 6) - 1
static

◆ Owner

readonly Entity Barotrauma.Inventory.Owner

◆ slots

readonly ItemSlot [] Barotrauma.Inventory.slots
protected

◆ syncItemsDelay

float Barotrauma.Inventory.syncItemsDelay
protected

Property Documentation

◆ AllItems

virtual IEnumerable<Item> Barotrauma.Inventory.AllItems
get

All items contained in the inventory. Stacked items are returned as individual instances. DO NOT modify the contents of the inventory while enumerating this list.

◆ AllItemsMod

IEnumerable<Item> Barotrauma.Inventory.AllItemsMod
get

All items contained in the inventory. Allows modifying the contents of the inventory while being enumerated.

◆ Capacity

int Barotrauma.Inventory.Capacity
get

◆ EmptySlotCount

int Barotrauma.Inventory.EmptySlotCount
get

◆ ExtraStackSize

int Barotrauma.Inventory.ExtraStackSize
getset

◆ IsDragAndDropGiveAllowed

bool Barotrauma.Inventory.IsDragAndDropGiveAllowed
staticget

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