Table of Contents

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 int
className string
instanceId string
api ICoreAPI
onNewSlot 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 int
invId string
api ICoreAPI
onNewSlot NewSlotDelegate

Fields

OnGetAutoPullFromSlot

public GetAutoPullFromSlotDelegate OnGetAutoPullFromSlot

Field Value

GetAutoPullFromSlotDelegate

OnGetAutoPushIntoSlot

public GetAutoPushIntoSlotDelegate OnGetAutoPushIntoSlot

Field Value

GetAutoPushIntoSlotDelegate

OnGetSuitability

public GetSuitabilityDelegate OnGetSuitability

Field Value

GetSuitabilityDelegate

slots

protected ItemSlot[] slots

Field Value

ItemSlot[]

Properties

BaseWeight

public float BaseWeight { get; set; }

Property Value

float

Count

Amount of available slots

public override int Count { get; }

Property Value

int

this[int]

Get slot for given slot index

public override ItemSlot this[int slotId] { get; set; }

Parameters

slotId int

Property Value

ItemSlot

PerishableFactorByFoodCategory

public Dictionary<EnumFoodCategory, float> PerishableFactorByFoodCategory { get; set; }

Property Value

Dictionary<EnumFoodCategory, float>

TransitionableSpeedMulByType

public Dictionary<EnumTransitionType, float> TransitionableSpeedMulByType { get; set; }

Property Value

Dictionary<EnumTransitionType, float>

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

ItemSlot

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 BlockFacing
fromSlot ItemSlot

Returns

ItemSlot

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

sourceSlot ItemSlot
targetSlot ItemSlot
isMerge bool

Returns

float

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 EnumTransitionType
stack ItemStack

Returns

float

NewSlot(int)

Called when initializing the inventory or when loading the contents

protected override ItemSlot NewSlot(int slotId)

Parameters

slotId int

Returns

ItemSlot

ToTreeAttributes(ITreeAttribute)

Stores the slot contents to invtree

public override void ToTreeAttributes(ITreeAttribute invtree)

Parameters

invtree ITreeAttribute