Show / Hide Table of Contents

Interface IMyInventory

Describes inventory interface (PB scripting interface)

Namespace: VRage.Game.ModAPI.Ingame
Assembly: VRage.Game.dll
Syntax
public interface IMyInventory

Properties

CanPutItems

Gets if inventory can receive items or not.

Declaration
bool CanPutItems { get; }
Property Value
Type Description
System.Boolean

CurrentMass

Returns total mass of items inside this inventory in Kg.

Declaration
MyFixedPoint CurrentMass { get; }
Property Value
Type Description
VRage.MyFixedPoint

CurrentVolume

Returns total volume of items inside this inventory in m^3.

Declaration
MyFixedPoint CurrentVolume { get; }
Property Value
Type Description
VRage.MyFixedPoint

IsFull

Determines if inventory is absolutely full.

Declaration
bool IsFull { get; }
Property Value
Type Description
System.Boolean

ItemCount

Returns number of occupied inventory slots.

Declaration
int ItemCount { get; }
Property Value
Type Description
System.Int32

MaxVolume

Sets maximum volume of items this inventory can contain in m^3.

Declaration
MyFixedPoint MaxVolume { get; }
Property Value
Type Description
VRage.MyFixedPoint

Owner

Returns entity this inventory belongs to.

Declaration
IMyEntity Owner { get; }
Property Value
Type Description
IMyEntity

VolumeFillFactor

Gets the current volume fill factor of the inventory

Declaration
float VolumeFillFactor { get; }
Property Value
Type Description
System.Single

Methods

CanItemsBeAdded(MyFixedPoint, MyItemType)

Determines if given amount of items fits into this inventory on top of existing items.

Declaration
bool CanItemsBeAdded(MyFixedPoint amount, MyItemType itemType)
Parameters
Type Name Description
VRage.MyFixedPoint amount

Amount of items being tested

MyItemType itemType

Type of items being tested

Returns
Type Description
System.Boolean

True if items can fit into this inventory on top of existing items, false otherwise

CanTransferItemTo(IMyInventory, MyItemType)

Determines if there is working conveyor connection for item of give type to be transferred to other inventory.

Declaration
bool CanTransferItemTo(IMyInventory otherInventory, MyItemType itemType)
Parameters
Type Name Description
IMyInventory otherInventory

Inventory to check the connection to

MyItemType itemType

Type of item to check the connection for

Returns
Type Description
System.Boolean

True if there is working conveyor connection between inventories so that item of give type can by transferred, false otherwise

ContainItems(MyFixedPoint, MyItemType)

Determines if there is at least given amount of items of given type contained inside this inventory.

Declaration
bool ContainItems(MyFixedPoint amount, MyItemType itemType)
Parameters
Type Name Description
VRage.MyFixedPoint amount

Threshold amount. Kg or count, based on item type

MyItemType itemType

Item type its amount is queried

Returns
Type Description
System.Boolean

True in case there is sufficient amount of items present inside this inventory, false otherwise

FindItem(MyItemType)

Tries to find an item of given type inside this inventory.

Declaration
Nullable<MyInventoryItem> FindItem(MyItemType itemType)
Parameters
Type Name Description
MyItemType itemType

Type of item being queried

Returns
Type Description
System.Nullable<MyInventoryItem>

Info about item found, null in case there is no item of given type inside this inventory

GetAcceptedItems(List<MyItemType>, Func<MyItemType, Boolean>)

Returns all items this inventory accepts.

Declaration
void GetAcceptedItems(List<MyItemType> itemsTypes, Func<MyItemType, bool> filter = null)
Parameters
Type Name Description
System.Collections.Generic.List<MyItemType> itemsTypes

Collection the item types info will be returned to

System.Func<MyItemType, System.Boolean> filter

Filter function you can use to decide whether to add item type into the itemsTypes collection or not

GetItemAmount(MyItemType)

Sums up total amount of items of given type contained inside this inventory.

Declaration
MyFixedPoint GetItemAmount(MyItemType itemType)
Parameters
Type Name Description
MyItemType itemType

Item type its amount is queried

Returns
Type Description
VRage.MyFixedPoint

Total amount of given item type contained inside this inventory. Kg or count, based on item type

GetItemAt(Int32)

Returns info about item at give position.

Declaration
Nullable<MyInventoryItem> GetItemAt(int index)
Parameters
Type Name Description
System.Int32 index

Zero-based index of queried inventory slot

Returns
Type Description
System.Nullable<MyInventoryItem>

Info about queried inventory slot, null in case there is no item at given slot

GetItemByID(UInt32)

Returns info about item contained inside this inventory.

Declaration
Nullable<MyInventoryItem> GetItemByID(uint id)
Parameters
Type Name Description
System.UInt32 id

Id of queried item

Returns
Type Description
System.Nullable<MyInventoryItem>

Info about queried item, null in case there is no item with given Id inside this inventory

GetItems(List<MyInventoryItem>, Func<MyInventoryItem, Boolean>)

Collects all items present inside this inventory and returns snapshot of the current inventory state.

Declaration
void GetItems(List<MyInventoryItem> items, Func<MyInventoryItem, bool> filter = null)
Parameters
Type Name Description
System.Collections.Generic.List<MyInventoryItem> items

Collection the item info will be returned to

System.Func<MyInventoryItem, System.Boolean> filter

Filter function you can use to decide whether to add item into the items collection or not

IsConnectedTo(IMyInventory)

Checks if two inventories are connected.

Declaration
bool IsConnectedTo(IMyInventory otherInventory)
Parameters
Type Name Description
IMyInventory otherInventory

Inventory to check the connection to

Returns
Type Description
System.Boolean

True if there is working conveyor connection between inventories, false otherwise

IsItemAt(Int32)

Determines if there is any item on given inventory slot.

Declaration
bool IsItemAt(int position)
Parameters
Type Name Description
System.Int32 position

Zero-based index of queried inventory slot

Returns
Type Description
System.Boolean

True in case given inventory slot is occupied, false otherwise

TransferItemFrom(IMyInventory, Int32, Nullable<Int32>, Nullable<Boolean>, Nullable<MyFixedPoint>)

Attempts to transfer item from one inventory to another.

Declaration
bool TransferItemFrom(IMyInventory sourceInventory, int sourceItemIndex, Nullable<int> targetItemIndex = null, Nullable<bool> stackIfPossible = null, Nullable<MyFixedPoint> amount = null)
Parameters
Type Name Description
IMyInventory sourceInventory

Inventory to transfer item from

System.Int32 sourceItemIndex

Zero-based index of inventory slot to transfer item from

System.Nullable<System.Int32> targetItemIndex

Zero-based index of inventory slot to transfer item to

System.Nullable<System.Boolean> stackIfPossible

If true, engine will attempt to stack items at destination inventory

System.Nullable<VRage.MyFixedPoint> amount

Amount that should be transferred. Kgs or count, based on item type

Returns
Type Description
System.Boolean

True in case item was successfully transferred, false otherwise

TransferItemFrom(IMyInventory, MyInventoryItem, Nullable<MyFixedPoint>)

Attempts to transfer item from one inventory to another.

Declaration
bool TransferItemFrom(IMyInventory sourceInventory, MyInventoryItem item, Nullable<MyFixedPoint> amount = null)
Parameters
Type Name Description
IMyInventory sourceInventory

Inventory to transfer item from

MyInventoryItem item

Item to transfer

System.Nullable<VRage.MyFixedPoint> amount

Amount that should be transferred. Kgs or count, based on item type

Returns
Type Description
System.Boolean

True in case item was successfully transferred, false otherwise

TransferItemTo(IMyInventory, Int32, Nullable<Int32>, Nullable<Boolean>, Nullable<MyFixedPoint>)

Attempts to transfer item from one inventory to another.

Declaration
bool TransferItemTo(IMyInventory dst, int sourceItemIndex, Nullable<int> targetItemIndex = null, Nullable<bool> stackIfPossible = null, Nullable<MyFixedPoint> amount = null)
Parameters
Type Name Description
IMyInventory dst

Inventory to transfer item to

System.Int32 sourceItemIndex

Zero-based index of inventory slot to transfer item from

System.Nullable<System.Int32> targetItemIndex

Zero-based index of inventory slot to transfer item to

System.Nullable<System.Boolean> stackIfPossible

If true, engine will attempt to stack items at destination inventory

System.Nullable<VRage.MyFixedPoint> amount

Amount that should be transferred. Kgs or count, based on item type

Returns
Type Description
System.Boolean

True in case item was successfully transferred, false otherwise

TransferItemTo(IMyInventory, MyInventoryItem, Nullable<MyFixedPoint>)

Attempts to transfer item from one inventory to another.

Declaration
bool TransferItemTo(IMyInventory dstInventory, MyInventoryItem item, Nullable<MyFixedPoint> amount = null)
Parameters
Type Name Description
IMyInventory dstInventory

Inventory to transfer item to

MyInventoryItem item

Item to transfer

System.Nullable<VRage.MyFixedPoint> amount

Amount that should be transferred. Kgs or count, based on item type

Returns
Type Description
System.Boolean

True in case item was successfully transferred, false otherwise

☀
☾
In This Article
  • Properties
    • CanPutItems
    • CurrentMass
    • CurrentVolume
    • IsFull
    • ItemCount
    • MaxVolume
    • Owner
    • VolumeFillFactor
  • Methods
    • CanItemsBeAdded(MyFixedPoint, MyItemType)
    • CanTransferItemTo(IMyInventory, MyItemType)
    • ContainItems(MyFixedPoint, MyItemType)
    • FindItem(MyItemType)
    • GetAcceptedItems(List<MyItemType>, Func<MyItemType, Boolean>)
    • GetItemAmount(MyItemType)
    • GetItemAt(Int32)
    • GetItemByID(UInt32)
    • GetItems(List<MyInventoryItem>, Func<MyInventoryItem, Boolean>)
    • IsConnectedTo(IMyInventory)
    • IsItemAt(Int32)
    • TransferItemFrom(IMyInventory, Int32, Nullable<Int32>, Nullable<Boolean>, Nullable<MyFixedPoint>)
    • TransferItemFrom(IMyInventory, MyInventoryItem, Nullable<MyFixedPoint>)
    • TransferItemTo(IMyInventory, Int32, Nullable<Int32>, Nullable<Boolean>, Nullable<MyFixedPoint>)
    • TransferItemTo(IMyInventory, MyInventoryItem, Nullable<MyFixedPoint>)
Back to top
Generated by DocFX
☀
☾