Barotrauma Client Doc
Barotrauma.ItemInventory Class Reference
Inheritance diagram for Barotrauma.ItemInventory:
Barotrauma.Inventory Barotrauma.Inventory

Public Member Functions

 ItemInventory (Item owner, ItemContainer container, int capacity, int slotsPerRow=5)
 
override int FindAllowedSlot (Item item, bool ignoreCondition=false)
 
override bool CanBePutInSlot (Item item, int i, bool ignoreCondition=false)
 Can the item be put in the specified slot. More...
 
override bool CanBePutInSlot (ItemPrefab itemPrefab, int i, float? condition, int? quality=null)
 
override int HowManyCanBePut (ItemPrefab itemPrefab, int i, float? condition, bool ignoreItemsInSlot=false)
 
override bool IsFull (bool takeStacksIntoAccount=false)
 Is there room to put more items in the inventory. Doesn't take stacking into account by default. More...
 
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 More...
 
override bool TryPutItem (Item item, int i, bool allowSwapping, bool allowCombine, Character user, bool createNetworkEvent=true, bool ignoreCondition=false)
 
override void RemoveItem (Item item)
 
override void Draw (SpriteBatch spriteBatch, bool subInventory=false)
 
void ClientEventWrite (IWriteMessage msg, Item.InventoryStateEventData extraData)
 
- 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. More...
 
Item FirstOrDefault ()
 Return the first item in the inventory, or null if the inventory is empty. More...
 
Item LastOrDefault ()
 Return the last item in the inventory, or null if the inventory is empty. More...
 
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. More...
 
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. More...
 
int GetItemStackSlotIndex (Item item, int index)
 
int FindIndex (Item item)
 Find the index of the first slot the item is contained in. More...
 
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. More...
 
virtual bool ItemOwnsSelf (Item item)
 Returns true if the item owns any of the parent inventories. More...
 
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). More...
 
bool CanBePut (ItemPrefab itemPrefab, float? condition=null, int? quality=null)
 
int HowManyCanBePut (ItemPrefab itemPrefab, float? condition=null)
 
bool IsEmpty ()
 
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! More...
 
void ForceRemoveFromSlot (Item item, int index)
 Removes an item from a specific slot. Doesn't do any sanity checks, use with caution! More...
 
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) More...
 
Inventory GetReplacementOrThiS ()
 
virtual void CreateSlots ()
 
bool Movable ()
 
bool IsInventoryHoverAvailable (Character owner, ItemContainer container)
 
virtual bool HideSlot (int i)
 
virtual void Update (float deltaTime, Camera cam, bool subInventory=false)
 
void UpdateSubInventory (float deltaTime, int slotIndex, Camera cam)
 
void ClearSubInventories ()
 
void DrawSubInventory (SpriteBatch spriteBatch, int slotIndex)
 
void ClientEventRead (IReadMessage msg)
 
void ApplyReceivedState ()
 

Protected Member Functions

override void CreateNetworkEvent (Range slotRange)
 
override void ControlInput (Camera cam)
 
override void CalculateBackgroundFrame ()
 
- Protected Member Functions inherited from Barotrauma.Inventory
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)
 
void UpdateSlot (VisualSlot slot, int slotIndex, Item item, bool isSubSlot)
 
Inventory GetSubInventory (int slotIndex)
 
virtual ItemInventory GetActiveEquippedSubInventory (int slotIndex)
 

Properties

ItemContainer Container [get]
 
- 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. More...
 
IEnumerable< ItemAllItemsMod [get]
 All items contained in the inventory. Allows modifying the contents of the inventory while being enumerated. More...
 
int Capacity [get]
 
int EmptySlotCount [get]
 
static float UIScale [get]
 
static int ContainedIndicatorHeight [get]
 
static Sprite SlotSpriteSmall [get]
 
Rectangle BackgroundFrame [get, protected set]
 
static bool DraggingItemToWorld [get]
 
int SlotsPerRow [set]
 
static SlotReference?? SelectedSlot [get]
 
static bool IsMouseOnInventory [get]
 

Additional Inherited Members

- Static Public Member Functions inherited from Barotrauma.Inventory
static bool IsMouseOnSlot (VisualSlot slot)
 Check if the mouse is hovering on top of the slot More...
 
static void RefreshMouseOnInventory ()
 Refresh the value of IsMouseOnInventory More...
 
static CursorState GetInventoryMouseCursor ()
 
static void UpdateDragging ()
 
static void DrawFront (SpriteBatch spriteBatch)
 
static void DrawSlot (SpriteBatch spriteBatch, Inventory inventory, VisualSlot slot, Item item, int slotIndex, bool drawItem=true, InvSlotType type=InvSlotType.Any)
 
- Public Attributes inherited from Barotrauma.Inventory
readonly Entity Owner
 
bool Locked
 
bool AllowSwappingContainedItems = true
 
Inventory ReplacedBy
 
float HideTimer
 
VisualSlot[] visualSlots
 
RectTransform RectTransform
 If set, the inventory is automatically positioned inside the rect More...
 
bool DrawWhenEquipped
 Normally false - we don't draw the UI because it's drawn when the player hovers the cursor over the item in their inventory. Enabled in special cases like equippable fabricators where the inventory is a part of the fabricator UI. More...
 
float OpenState
 
- Static Public Attributes inherited from Barotrauma.Inventory
const int MaxPossibleStackSize = (1 << 6) - 1
 
const int MaxItemsPerNetworkEvent = 128
 
static Sprite DraggableIndicator
 
static Sprite UnequippedIndicator
 
static Inventory DraggingInventory
 
static VisualSlot DraggingSlot
 
static readonly List< ItemDraggingItems = new List<Item>()
 
static readonly List< ItemdoubleClickedItems = new List<Item>()
 
- Static Protected Member Functions inherited from Barotrauma.Inventory
static void DrawToolTip (SpriteBatch spriteBatch, RichString toolTip, Rectangle highlightedSlot)
 
static Rectangle GetSubInventoryHoverArea (SlotReference subSlot)
 
- Protected Attributes inherited from Barotrauma.Inventory
readonly int capacity
 
readonly ItemSlot[] slots
 
float syncItemsDelay
 
float prevUIScale = UIScale
 
float prevHUDScale = GUI.Scale
 
Point prevScreenResolution
 
Vector4 padding
 
- Static Protected Attributes inherited from Barotrauma.Inventory
static Sprite slotHotkeySprite
 
static HashSet< SlotReferencehighlightedSubInventorySlots = new HashSet<SlotReference>()
 
static SlotReference selectedSlot
 

Detailed Description

Constructor & Destructor Documentation

◆ ItemInventory()

Barotrauma.ItemInventory.ItemInventory ( Item  owner,
ItemContainer  container,
int  capacity,
int  slotsPerRow = 5 
)

Member Function Documentation

◆ CalculateBackgroundFrame()

override void Barotrauma.ItemInventory.CalculateBackgroundFrame ( )
protectedvirtual

Reimplemented from Barotrauma.Inventory.

Definition at line 25 of file BarotraumaClient/ClientSource/Items/ItemInventory.cs.

◆ CanBePutInSlot() [1/2]

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

Can the item be put in the specified slot.

Reimplemented from Barotrauma.Inventory.

Definition at line 46 of file BarotraumaShared/SharedSource/Items/ItemInventory.cs.

◆ CanBePutInSlot() [2/2]

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

Reimplemented from Barotrauma.Inventory.

Definition at line 54 of file BarotraumaShared/SharedSource/Items/ItemInventory.cs.

◆ ClientEventWrite()

void Barotrauma.ItemInventory.ClientEventWrite ( IWriteMessage  msg,
Item.InventoryStateEventData  extraData 
)

◆ ControlInput()

override void Barotrauma.ItemInventory.ControlInput ( Camera  cam)
protectedvirtual

Reimplemented from Barotrauma.Inventory.

Definition at line 10 of file BarotraumaClient/ClientSource/Items/ItemInventory.cs.

◆ CreateNetworkEvent()

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

Reimplemented from Barotrauma.Inventory.

Definition at line 136 of file BarotraumaShared/SharedSource/Items/ItemInventory.cs.

◆ Draw()

override void Barotrauma.ItemInventory.Draw ( SpriteBatch  spriteBatch,
bool  subInventory = false 
)
virtual

Reimplemented from Barotrauma.Inventory.

Definition at line 44 of file BarotraumaClient/ClientSource/Items/ItemInventory.cs.

◆ FindAllowedSlot()

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

Reimplemented from Barotrauma.Inventory.

Definition at line 24 of file BarotraumaShared/SharedSource/Items/ItemInventory.cs.

◆ HowManyCanBePut()

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

Reimplemented from Barotrauma.Inventory.

Definition at line 61 of file BarotraumaShared/SharedSource/Items/ItemInventory.cs.

◆ IsFull()

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

Definition at line 69 of file BarotraumaShared/SharedSource/Items/ItemInventory.cs.

◆ RemoveItem()

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

Reimplemented from Barotrauma.Inventory.

Definition at line 167 of file BarotraumaShared/SharedSource/Items/ItemInventory.cs.

◆ TryPutItem() [1/2]

override bool Barotrauma.ItemInventory.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.

Definition at line 91 of file BarotraumaShared/SharedSource/Items/ItemInventory.cs.

◆ TryPutItem() [2/2]

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

Reimplemented from Barotrauma.Inventory.

Definition at line 114 of file BarotraumaShared/SharedSource/Items/ItemInventory.cs.

Property Documentation

◆ Container

ItemContainer Barotrauma.ItemInventory.Container
get