IMyInventory

From Space Engineers Wiki
Jump to: navigation, search

Summary

Properties

Owner

Returns entity this inventory belongs to.

IMyEntity Owner { get; }

IsFull

Determines if inventory is absolutely full.

bool IsFull { get; }

CurrentMass

Returns total mass of items inside this inventory in Kg.

MyFixedPoint CurrentMass { get; }

MaxVolume

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

MyFixedPoint MaxVolume { get; }

CurrentVolume

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

MyFixedPoint CurrentVolume { get; }

ItemCount

Returns number of occupied inventory slots.

int ItemCount { get; }

Methods

IsItemAt

Determines if there is any item on given inventory slot.

bool IsItemAt(int position);

position Zero-based index of queried inventory slot

returns True in case given inventory slot is occupied, false otherwise

GetItemAmount

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

MyFixedPoint GetItemAmount(MyItemType itemType);

itemType Item type its amount is queried

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

ContainItems

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

bool ContainItems(MyFixedPoint amount, MyItemType itemType);

amount Threshold amount. Kg or count, based on item type

itemType Item type its amount is queried

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

GetItemAt

Returns info about item at give position.

MyInventoryItem? GetItemAt(int index);

index Zero-based index of queried inventory slot

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

GetItemByID

Returns info about item contained inside this inventory.

MyInventoryItem? GetItemByID(uint id);

id Id of queried item

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

FindItem

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

MyInventoryItem? FindItem(MyItemType itemType);

itemType Type of item being queried

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

CanItemsBeAdded

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

bool CanItemsBeAdded(MyFixedPoint amount, MyItemType itemType);

amount Amount of items being tested

itemType Type of items being tested

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

GetItems

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

void GetItems(List<MyInventoryItem> items, Func<MyInventoryItem, bool> filter = null);

items Collection the item info will be returned to

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

TransferItemTo

Attempts to transfer item from one inventory to another.

bool TransferItemTo(IMyInventory dstInventory, MyInventoryItem item, MyFixedPoint? amount = null);

dstInventory Inventory to transfer item to

item Item to transfer

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

returns True in case item was successfully transferred, false otherwise

TransferItemTo

Attempts to transfer item from one inventory to another.

bool TransferItemTo(IMyInventory dst, int sourceItemIndex, int? targetItemIndex = null, bool? stackIfPossible = null, MyFixedPoint? amount = null);

dst Inventory to transfer item to

sourceItemIndex Zero-based index of inventory slot to transfer item from

targetItemIndex Zero-based index of inventory slot to transfer item to

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

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

returns True in case item was successfully transferred, false otherwise

TransferItemFrom

Attempts to transfer item from one inventory to another.

bool TransferItemFrom(IMyInventory sourceInventory, MyInventoryItem item, MyFixedPoint? amount = null);

sourceInventory Inventory to transfer item from

item Item to transfer

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

returns True in case item was successfully transferred, false otherwise

TransferItemFrom

Attempts to transfer item from one inventory to another.

bool TransferItemFrom(IMyInventory sourceInventory, int sourceItemIndex, int? targetItemIndex = null, bool? stackIfPossible = null, MyFixedPoint? amount = null);

sourceInventory Inventory to transfer item from

sourceItemIndex Zero-based index of inventory slot to transfer item from

targetItemIndex Zero-based index of inventory slot to transfer item to

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

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

returns True in case item was successfully transferred, false otherwise

IsConnectedTo

Checks if two inventories are connected.

bool IsConnectedTo(IMyInventory otherInventory);

otherInventory Inventory to check the connection to

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

CanTransferItemTo

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

bool CanTransferItemTo(IMyInventory otherInventory, MyItemType itemType);

otherInventory Inventory to check the connection to

itemType Type of item to check the connection for

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

GetAcceptedItems

Returns all items this inventory accepts.

void GetAcceptedItems(List<MyItemType> itemsTypes, Func<MyItemType, bool> filter = null);

itemsTypes Collection the item types info will be returned to

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

Derived Types