Interface IMyInventory
Describes inventory interface (PB scripting interface) You can cast if MyInventory for getting more functionality
Inherited Members
Namespace: VRage.Game.ModAPI
Assembly: VRage.Game.dll
Syntax
public interface IMyInventory : IMyInventory
Properties
CanPutItems
Gets or sets if inventory can receive items or not.
Declaration
bool CanPutItems { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Owner
Returns entity this inventory belongs to.
Declaration
IMyEntity Owner { get; }
Property Value
Type | Description |
---|---|
IMyEntity |
Methods
AddItems(MyFixedPoint, MyObjectBuilder_PhysicalObject, Int32)
Adds item to inventory. Doesn't do all checks inside. Call CanAddItemAmount(IMyInventoryItem, MyFixedPoint) before this function
Declaration
void AddItems(MyFixedPoint amount, MyObjectBuilder_PhysicalObject objectBuilder, int index = -1)
Parameters
Type | Name | Description |
---|---|---|
VRage.MyFixedPoint | amount | Amount of items |
MyObjectBuilder_PhysicalObject | objectBuilder | Builder of item to add |
System.Int32 | index | Position to add, starting from 0 |
CanAddItemAmount(IMyInventoryItem, MyFixedPoint)
Gets whether item could be added into inventory, but doesn't add it Checks:
- Inserting volume
- Inventory can receive items
- Inventory filter can
Declaration
bool CanAddItemAmount(IMyInventoryItem item, MyFixedPoint amount)
Parameters
Type | Name | Description |
---|---|---|
IMyInventoryItem | item | Item that you want to add |
VRage.MyFixedPoint | amount | Amount of items |
Returns
Type | Description |
---|---|
System.Boolean | True if item can be added |
Clear(Boolean)
Remove all items from inventory
Declaration
void Clear(bool sync = true)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | sync | If you need send clear event for clients too |
Empty()
Gets if inventory is empty
Declaration
bool Empty()
Returns
Type | Description |
---|---|
System.Boolean | Try if there is no items |
FindItem(SerializableDefinitionId)
Finds first item stack, whose content matching provided id
Declaration
IMyInventoryItem FindItem(SerializableDefinitionId contentId)
Parameters
Type | Name | Description |
---|---|---|
SerializableDefinitionId | contentId | Definition id. Example MyObjectBuilder |
Returns
Type | Description |
---|---|
IMyInventoryItem | Item |
GetItemByID(UInt32)
Gets item by id
Declaration
IMyInventoryItem GetItemByID(uint id)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | id | Id of items |
Returns
Type | Description |
---|---|
IMyInventoryItem | Item |
GetItems()
Declaration
List<IMyInventoryItem> GetItems()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<IMyInventoryItem> |
RemoveItemAmount(IMyInventoryItem, MyFixedPoint)
Remove
Declaration
void RemoveItemAmount(IMyInventoryItem item, MyFixedPoint amount)
Parameters
Type | Name | Description |
---|---|---|
IMyInventoryItem | item | Item to remove |
VRage.MyFixedPoint | amount | Amount to remove |
RemoveItems(UInt32, Nullable<MyFixedPoint>, Boolean, Boolean)
Removes item by itemId
Declaration
void RemoveItems(uint itemId, Nullable<MyFixedPoint> amount = null, bool sendEvent = true, bool spawn = false)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | itemId | Item id of item you want to remove. See |
System.Nullable<VRage.MyFixedPoint> | amount | Amount to remove or null. When null whole item stack would be removed |
System.Boolean | sendEvent | Should synchronize to clients or not |
System.Boolean | spawn | Should spawn as floating object or not |
RemoveItemsAt(Int32, Nullable<MyFixedPoint>, Boolean, Boolean)
Removes items at exact inventory index
Declaration
void RemoveItemsAt(int itemIndex, Nullable<MyFixedPoint> amount = null, bool sendEvent = true, bool spawn = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | itemIndex | Starting from 0 |
System.Nullable<VRage.MyFixedPoint> | amount | Amount to remove or null. When null whole item stack would be removed |
System.Boolean | sendEvent | Should synchronize to clients or not |
System.Boolean | spawn | Should spawn as floating object or not |
RemoveItemsOfType(MyFixedPoint, MyObjectBuilder_PhysicalObject, Boolean)
Removes amount for specified item type from inventory
Declaration
void RemoveItemsOfType(MyFixedPoint amount, MyObjectBuilder_PhysicalObject objectBuilder, bool spawn = false)
Parameters
Type | Name | Description |
---|---|---|
VRage.MyFixedPoint | amount | Amount of items should be removed |
MyObjectBuilder_PhysicalObject | objectBuilder | Item type to remove |
System.Boolean | spawn | Should be removed items be spawned as floating items |
RemoveItemsOfType(MyFixedPoint, SerializableDefinitionId, MyItemFlags, Boolean)
Removes amount for specified item type from inventory
Declaration
void RemoveItemsOfType(MyFixedPoint amount, SerializableDefinitionId contentId, MyItemFlags flags, bool spawn = false)
Parameters
Type | Name | Description |
---|---|---|
VRage.MyFixedPoint | amount | Amount of items |
SerializableDefinitionId | contentId | Item id |
MyItemFlags | flags | Not supported. Use None |
System.Boolean | spawn | Should be removed items be spawned as floating items |
TransferItemFrom(IMyInventory, Int32, Nullable<Int32>, Nullable<Boolean>, Nullable<MyFixedPoint>, Boolean)
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, bool checkConnection = true)
Parameters
Type | Name | Description |
---|---|---|
IMyInventory | sourceInventory | Inventory that would give item |
System.Int32 | sourceItemIndex | Index of item in inventory that would give item |
System.Nullable<System.Int32> | targetItemIndex | Index of item in this inventory. You may use null, to add to existing stack, or as last item |
System.Nullable<System.Boolean> | stackIfPossible | When false, would add always create new item stack |
System.Nullable<VRage.MyFixedPoint> | amount | Transferred item amount |
System.Boolean | checkConnection | Check if two inventories connected with conveyor needed size |
Returns
Type | Description |
---|---|
System.Boolean | True if checkConnection is false, or inventories are connected with correct conveyor |
TransferItemFrom(IMyInventory, IMyInventoryItem, MyFixedPoint)
Transfer item from one inventory to another
Declaration
bool TransferItemFrom(IMyInventory sourceInventory, IMyInventoryItem item, MyFixedPoint amount)
Parameters
Type | Name | Description |
---|---|---|
IMyInventory | sourceInventory | Inventory that would give item |
IMyInventoryItem | item | Item in sourceInventory |
VRage.MyFixedPoint | amount | Transferred item amount |
Returns
Type | Description |
---|---|
System.Boolean | True if two inventories are connected |
Remarks
Items could be transferred only through conveyors
TransferItemTo(IMyInventory, Int32, Nullable<Int32>, Nullable<Boolean>, Nullable<MyFixedPoint>, Boolean)
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, bool checkConnection = true)
Parameters
Type | Name | Description |
---|---|---|
IMyInventory | dst | Inventory that would receive item |
System.Int32 | sourceItemIndex | This inventory index |
System.Nullable<System.Int32> | targetItemIndex | Dst inventory item index. You may use null, to add to existing stack, or as last item |
System.Nullable<System.Boolean> | stackIfPossible | When false, would add always create new item stack |
System.Nullable<VRage.MyFixedPoint> | amount | Transferred item amount |
System.Boolean | checkConnection | Check if two inventories connected with conveyor needed size |
Returns
Type | Description |
---|---|
System.Boolean | True if checkConnection is false, or inventories are connected with correct conveyor |
Events
OnVolumeChanged
Triggers when volume of the inventory is changed
Declaration
event Action<IMyInventory, float, float> OnVolumeChanged
Event Type
Type | Description |
---|---|
System.Action<IMyInventory, System.Single, System.Single> |