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

Public Types

enum  AccessLevel { Restricted , Limited , Allowed }
 How much access other characters have to the inventory? Restricted = Only accessible when character is knocked down or handcuffed. Limited = Can also access inventories of bots on the same team and friendly pets. Allowed = Can also access other players in the same team (used for drag and drop give). More...
 

Public Member Functions

 CharacterInventory (ContentXElement element, Character character, bool spawnInitialItems)
 
Item FindEquippedItemByTag (Identifier tag)
 
int FindLimbSlot (InvSlotType limbSlot)
 
Item GetItemInLimbSlot (InvSlotType limbSlot)
 
bool IsInLimbSlot (Item item, InvSlotType limbSlot)
 
override bool CanBePutInSlot (Item item, int i, bool ignoreCondition=false)
 Can the item be put in the specified slot.
 
override bool CanBePutInSlot (ItemPrefab itemPrefab, int i, float? condition, int? quality=null)
 
override void RemoveItem (Item item)
 
void RemoveItem (Item item, bool tryEquipFromSameStack)
 
bool TryPutItemWithAutoEquipCheck (Item item, Character user, IEnumerable< InvSlotType > allowedSlots=null, bool createNetworkEvent=true)
 If there is no room in the generic inventory (InvSlotType.Any), check if the item can be auto-equipped into its respective limbslot.
 
override 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.
 
bool IsAnySlotAvailable (Item item)
 
override bool TryPutItem (Item item, int index, bool allowSwapping, bool allowCombine, Character user, bool createNetworkEvent=true, bool ignoreCondition=false)
 
- Public Member Functions inherited from Barotrauma.Inventory
 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).
 
bool CanBePut (ItemPrefab itemPrefab, 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)
 
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)
 
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)
 

Static Public Member Functions

static bool IsHandSlotType (InvSlotType s)
 

Static Public Attributes

static readonly List< InvSlotTypeAnySlot = new List<InvSlotType>() { InvSlotType.Any }
 
- Static Public Attributes inherited from Barotrauma.Inventory
const int MaxPossibleStackSize = (1 << 6) - 1
 
const int MaxItemsPerNetworkEvent = 128
 

Protected Member Functions

override void PutItem (Item item, int i, Character user, bool removeItem=true, bool createNetworkEvent=true)
 
override void CreateNetworkEvent (Range slotRange)
 
- Protected Member Functions inherited from Barotrauma.Inventory
IEnumerable< ItemGetAllItems (bool checkForDuplicates)
 
bool TrySwapping (int index, Item item, Character user, bool createNetworkEvent, bool swapWholeStack)
 

Protected Attributes

bool[] IsEquipped
 
- Protected Attributes inherited from Barotrauma.Inventory
readonly int capacity
 Capacity, or the number of slots in the inventory.
 
readonly ItemSlot[] slots
 
float syncItemsDelay
 

Properties

InvSlotType[] SlotTypes [get]
 
bool AccessibleWhenAlive [get]
 Can the inventory be accessed when the character is still alive.
 
bool AccessibleByOwner [get]
 Can the inventory be accessed by the character itself when the character is still alive (only has an effect if AccessibleWhenAlive false)
 
- Properties inherited from Barotrauma.Inventory
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]
 

Additional Inherited Members

- Public Attributes inherited from Barotrauma.Inventory
readonly Entity Owner
 
bool Locked
 
bool AllowSwappingContainedItems = true
 

Member Enumeration Documentation

◆ AccessLevel

How much access other characters have to the inventory? Restricted = Only accessible when character is knocked down or handcuffed. Limited = Can also access inventories of bots on the same team and friendly pets. Allowed = Can also access other players in the same team (used for drag and drop give).

Enumerator
Restricted 
Limited 
Allowed 

Constructor & Destructor Documentation

◆ CharacterInventory()

Barotrauma.CharacterInventory.CharacterInventory ( ContentXElement element,
Character character,
bool spawnInitialItems )

Member Function Documentation

◆ CanBePutInSlot() [1/2]

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

Can the item be put in the specified slot.

Reimplemented from Barotrauma.Inventory.

◆ CanBePutInSlot() [2/2]

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

Reimplemented from Barotrauma.Inventory.

◆ CreateNetworkEvent()

override void Barotrauma.CharacterInventory.CreateNetworkEvent ( Range slotRange)
protectedvirtual

Reimplemented from Barotrauma.Inventory.

◆ FindEquippedItemByTag()

Item Barotrauma.CharacterInventory.FindEquippedItemByTag ( Identifier tag)

◆ FindLimbSlot()

int Barotrauma.CharacterInventory.FindLimbSlot ( InvSlotType limbSlot)

◆ GetItemInLimbSlot()

Item Barotrauma.CharacterInventory.GetItemInLimbSlot ( InvSlotType limbSlot)

◆ IsAnySlotAvailable()

bool Barotrauma.CharacterInventory.IsAnySlotAvailable ( Item item)

◆ IsHandSlotType()

static bool Barotrauma.CharacterInventory.IsHandSlotType ( InvSlotType s)
static

◆ IsInLimbSlot()

bool Barotrauma.CharacterInventory.IsInLimbSlot ( Item item,
InvSlotType limbSlot )

◆ PutItem()

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

Reimplemented from Barotrauma.Inventory.

◆ RemoveItem() [1/2]

override void Barotrauma.CharacterInventory.RemoveItem ( Item item)
virtual

Reimplemented from Barotrauma.Inventory.

◆ RemoveItem() [2/2]

void Barotrauma.CharacterInventory.RemoveItem ( Item item,
bool tryEquipFromSameStack )

◆ TryPutItem() [1/2]

override bool Barotrauma.CharacterInventory.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 from Barotrauma.Inventory.

◆ TryPutItem() [2/2]

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

Reimplemented from Barotrauma.Inventory.

◆ TryPutItemWithAutoEquipCheck()

bool Barotrauma.CharacterInventory.TryPutItemWithAutoEquipCheck ( Item item,
Character user,
IEnumerable< InvSlotType > allowedSlots = null,
bool createNetworkEvent = true )

If there is no room in the generic inventory (InvSlotType.Any), check if the item can be auto-equipped into its respective limbslot.

Member Data Documentation

◆ AnySlot

readonly List<InvSlotType> Barotrauma.CharacterInventory.AnySlot = new List<InvSlotType>() { InvSlotType.Any }
static

◆ IsEquipped

bool [] Barotrauma.CharacterInventory.IsEquipped
protected

Property Documentation

◆ AccessibleByOwner

bool Barotrauma.CharacterInventory.AccessibleByOwner
get

Can the inventory be accessed by the character itself when the character is still alive (only has an effect if AccessibleWhenAlive false)

◆ AccessibleWhenAlive

bool Barotrauma.CharacterInventory.AccessibleWhenAlive
get

Can the inventory be accessed when the character is still alive.

◆ SlotTypes

InvSlotType [] Barotrauma.CharacterInventory.SlotTypes
get

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