Class InventoryGeneric
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
A general purpose inventory
public class InventoryGeneric : InventoryBase, IInventory, IReadOnlyCollection<ItemSlot>, IEnumerable<ItemSlot>, IEnumerable
- Inheritance
-
InventoryGeneric
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
InventoryGeneric(int, string, string, ICoreAPI, NewSlotDelegate)
Create a new general purpose inventory
public InventoryGeneric(int quantitySlots, string className, string instanceId, ICoreAPI api, NewSlotDelegate onNewSlot = null)
Parameters
quantitySlots
intclassName
stringinstanceId
stringapi
ICoreAPIonNewSlot
NewSlotDelegate
InventoryGeneric(int, string, ICoreAPI, NewSlotDelegate)
Create a new general purpose inventory
public InventoryGeneric(int quantitySlots, string invId, ICoreAPI api, NewSlotDelegate onNewSlot = null)
Parameters
quantitySlots
intinvId
stringapi
ICoreAPIonNewSlot
NewSlotDelegate
InventoryGeneric(ICoreAPI)
Creates an empty (invalid) inventory. Must call init() to propery init the inventory
public InventoryGeneric(ICoreAPI api)
Parameters
api
ICoreAPI
Fields
OnGetAutoPullFromSlot
public GetAutoPullFromSlotDelegate OnGetAutoPullFromSlot
Field Value
OnGetAutoPushIntoSlot
public GetAutoPushIntoSlotDelegate OnGetAutoPushIntoSlot
Field Value
OnGetSuitability
public GetSuitabilityDelegate OnGetSuitability
Field Value
slots
protected ItemSlot[] slots
Field Value
- ItemSlot[]
Properties
BaseWeight
public float BaseWeight { get; set; }
Property Value
Count
Amount of available slots
public override int Count { get; }
Property Value
this[int]
Get slot for given slot index
public override ItemSlot this[int slotId] { get; set; }
Parameters
slotId
int
Property Value
PerishableFactorByFoodCategory
public Dictionary<EnumFoodCategory, float> PerishableFactorByFoodCategory { get; set; }
Property Value
TransitionableSpeedMulByType
public Dictionary<EnumTransitionType, float> TransitionableSpeedMulByType { get; set; }
Property Value
Methods
AddSlots(int)
public void AddSlots(int amount)
Parameters
amount
int
FromTreeAttributes(ITreeAttribute)
Loads the slot contents from given treeAttribute
public override void FromTreeAttributes(ITreeAttribute treeAttribute)
Parameters
treeAttribute
ITreeAttribute
GetAutoPullFromSlot(BlockFacing)
Return the slot where a chute may pull items from. Return null if it is now allowed to pull any items from this inventory
public override ItemSlot GetAutoPullFromSlot(BlockFacing atBlockFace)
Parameters
atBlockFace
BlockFacing
Returns
GetAutoPushIntoSlot(BlockFacing, ItemSlot)
Return the slot where a chute may push items into. Return null if it shouldn't move items into this inventory.
public override ItemSlot GetAutoPushIntoSlot(BlockFacing atBlockFace, ItemSlot fromSlot)
Parameters
atBlockFace
BlockFacingfromSlot
ItemSlot
Returns
GetSuitability(ItemSlot, ItemSlot, bool)
How well a stack fits into this inventory. By default 1 for new itemstacks and 3 for an itemstack merge. Chests and other stationary container also add a +1 to the suitability if the source slot is from the players inventory.
public override float GetSuitability(ItemSlot sourceSlot, ItemSlot targetSlot, bool isMerge)
Parameters
Returns
GetTransitionSpeedMul(EnumTransitionType, ItemStack)
Does this inventory speed up or slow down a transition for given itemstack? (Default: 1 for perish and 0 otherwise)
public override float GetTransitionSpeedMul(EnumTransitionType transType, ItemStack stack)
Parameters
transType
EnumTransitionTypestack
ItemStack
Returns
Init(int, string, string, NewSlotDelegate)
public void Init(int quantitySlots, string className, string instanceId, NewSlotDelegate onNewSlot = null)
Parameters
quantitySlots
intclassName
stringinstanceId
stringonNewSlot
NewSlotDelegate
NewSlot(int)
Called when initializing the inventory or when loading the contents
protected override ItemSlot NewSlot(int slotId)
Parameters
slotId
int
Returns
ToTreeAttributes(ITreeAttribute)
Stores the slot contents to invtree
public override void ToTreeAttributes(ITreeAttribute invtree)
Parameters
invtree
ITreeAttribute