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. |
CurrentMass
Returns total mass of items inside this inventory in Kg.
Declaration
MyFixedPoint CurrentMass { get; }
Property Value
Type | Description |
---|---|
VRage. |
CurrentVolume
Returns total volume of items inside this inventory in m^3.
Declaration
MyFixedPoint CurrentVolume { get; }
Property Value
Type | Description |
---|---|
VRage. |
IsFull
Determines if inventory is absolutely full.
Declaration
bool IsFull { get; }
Property Value
Type | Description |
---|---|
System. |
ItemCount
Returns number of occupied inventory slots.
Declaration
int ItemCount { get; }
Property Value
Type | Description |
---|---|
System. |
MaxVolume
Sets maximum volume of items this inventory can contain in m^3.
Declaration
MyFixedPoint MaxVolume { get; }
Property Value
Type | Description |
---|---|
VRage. |
Owner
Returns entity this inventory belongs to.
Declaration
IMyEntity Owner { get; }
Property Value
Type | Description |
---|---|
IMy |
VolumeFillFactor
Gets the current volume fill factor of the inventory
Declaration
float VolumeFillFactor { get; }
Property Value
Type | Description |
---|---|
System. |
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. |
amount | Amount of items being tested |
My |
itemType | Type of items being tested |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
IMy |
otherInventory | Inventory to check the connection to |
My |
itemType | Type of item to check the connection for |
Returns
Type | Description |
---|---|
System. |
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. |
amount | Threshold amount. Kg or count, based on item type |
My |
itemType | Item type its amount is queried |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
My |
itemType | Type of item being queried |
Returns
Type | Description |
---|---|
System. |
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. |
itemsTypes | Collection the item types info will be returned to |
System. |
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 |
---|---|---|
My |
itemType | Item type its amount is queried |
Returns
Type | Description |
---|---|
VRage. |
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. |
index | Zero-based index of queried inventory slot |
Returns
Type | Description |
---|---|
System. |
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. |
id | Id of queried item |
Returns
Type | Description |
---|---|
System. |
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. |
items | Collection the item info will be returned to |
System. |
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 |
---|---|---|
IMy |
otherInventory | Inventory to check the connection to |
Returns
Type | Description |
---|---|
System. |
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. |
position | Zero-based index of queried inventory slot |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
IMy |
sourceInventory | Inventory to transfer item from |
System. |
sourceItemIndex | Zero-based index of inventory slot to transfer item from |
System. |
targetItemIndex | Zero-based index of inventory slot to transfer item to |
System. |
stackIfPossible | If true, engine will attempt to stack items at destination inventory |
System. |
amount | Amount that should be transferred. Kgs or count, based on item type |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
IMy |
sourceInventory | Inventory to transfer item from |
My |
item | Item to transfer |
System. |
amount | Amount that should be transferred. Kgs or count, based on item type |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
IMy |
dst | Inventory to transfer item to |
System. |
sourceItemIndex | Zero-based index of inventory slot to transfer item from |
System. |
targetItemIndex | Zero-based index of inventory slot to transfer item to |
System. |
stackIfPossible | If true, engine will attempt to stack items at destination inventory |
System. |
amount | Amount that should be transferred. Kgs or count, based on item type |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
IMy |
dstInventory | Inventory to transfer item to |
My |
item | Item to transfer |
System. |
amount | Amount that should be transferred. Kgs or count, based on item type |
Returns
Type | Description |
---|---|
System. |
True in case item was successfully transferred, false otherwise |