Class MyInventoryBase
Inheritance
System.Object
MyInventoryBase
Assembly: VRage.Game.dll
Syntax
[MyComponentType]
[StaticEventOwner]
public abstract class MyInventoryBase : MyEntityComponentBase, IMyEntityComponentBase, IMyComponentBase, IMyEventProxy, IMyEventOwner
Constructors
MyInventoryBase(String)
Declaration
public MyInventoryBase(string inventoryId)
Parameters
| Type |
Name |
Description |
| System.String |
inventoryId |
|
Fields
CanPutItems
Declaration
Field Value
| Type |
Description |
| System.Boolean |
|
IsInModifyInventory
Declaration
public bool IsInModifyInventory
Field Value
| Type |
Description |
| System.Boolean |
|
RemoveEntityOnEmpty
Setting this flag to true causes to call Close() on the Entity of Container, when the GetItemsCount() == 0.
This causes to remove entity from the world, when this inventory is empty.
Declaration
public bool RemoveEntityOnEmpty
Field Value
| Type |
Description |
| System.Boolean |
|
Properties
AttachSyncToEntity
Declaration
public override bool AttachSyncToEntity { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
Overrides
ComponentTypeDebugString
Declaration
public override string ComponentTypeDebugString { get; }
Property Value
| Type |
Description |
| System.String |
|
Overrides
CurrentMass
Declaration
public abstract MyFixedPoint CurrentMass { get; }
Property Value
| Type |
Description |
| VRage.MyFixedPoint |
|
CurrentVolume
Declaration
public abstract MyFixedPoint CurrentVolume { get; }
Property Value
| Type |
Description |
| VRage.MyFixedPoint |
|
ForcedPriority
Declaration
public abstract Nullable<float> ForcedPriority { get; set; }
Property Value
| Type |
Description |
| System.Nullable<System.Single> |
|
InventoryId
This is for the purpose of identifying the inventory in aggregates (i.e. "Backpack", "LeftHand", ...)
Declaration
public MyStringHash InventoryId { get; }
Property Value
MaxItemCount
Declaration
public abstract int MaxItemCount { get; }
Property Value
| Type |
Description |
| System.Int32 |
|
MaxMass
Declaration
public abstract MyFixedPoint MaxMass { get; }
Property Value
| Type |
Description |
| VRage.MyFixedPoint |
|
MaxVolume
Declaration
public abstract MyFixedPoint MaxVolume { get; set; }
Property Value
| Type |
Description |
| VRage.MyFixedPoint |
|
Methods
Add(IMyInventoryItem, MyFixedPoint)
Declaration
public abstract bool Add(IMyInventoryItem item, MyFixedPoint amount)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
AddItems(MyFixedPoint, MyObjectBuilder_Base)
Declaration
public abstract bool AddItems(MyFixedPoint amount, MyObjectBuilder_Base objectBuilder)
Parameters
Returns
| Type |
Description |
| System.Boolean |
true if items were added, false if items didn't fit
|
ApplyChanges(List<MyComponentChange>)
Declaration
public abstract void ApplyChanges(List<MyComponentChange> changes)
Parameters
ComputeAmountThatFits(MyDefinitionId, Single, Single)
Declaration
public abstract MyFixedPoint ComputeAmountThatFits(MyDefinitionId contentId, float volumeRemoved = 0F, float massRemoved = 0F)
Parameters
| Type |
Name |
Description |
| MyDefinitionId |
contentId |
|
| System.Single |
volumeRemoved |
|
| System.Single |
massRemoved |
|
Returns
| Type |
Description |
| VRage.MyFixedPoint |
|
ConsumeItem(MyDefinitionId, MyFixedPoint, Int64)
Declaration
public abstract void ConsumeItem(MyDefinitionId itemId, MyFixedPoint amount, long consumerEntityId = 0L)
Parameters
| Type |
Name |
Description |
| MyDefinitionId |
itemId |
|
| VRage.MyFixedPoint |
amount |
|
| System.Int64 |
consumerEntityId |
|
CountItems(Dictionary<MyDefinitionId, MyFixedPoint>)
Declaration
public abstract void CountItems(Dictionary<MyDefinitionId, MyFixedPoint> itemCounts)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.Dictionary<MyDefinitionId, VRage.MyFixedPoint> |
itemCounts |
|
Deserialize(MyObjectBuilder_ComponentBase)
Declaration
public override void Deserialize(MyObjectBuilder_ComponentBase builder)
Parameters
Overrides
GetInventoryCount()
Returns number of embedded inventories - this inventory can be aggregation of other inventories.
Declaration
public abstract int GetInventoryCount()
Returns
| Type |
Description |
| System.Int32 |
Return one for simple inventory, different number when this instance is an aggregation.
|
GetItemAmount(MyDefinitionId, MyItemFlags, Boolean)
Declaration
public abstract MyFixedPoint GetItemAmount(MyDefinitionId contentId, MyItemFlags flags, bool substitute = false)
Parameters
Returns
| Type |
Description |
| VRage.MyFixedPoint |
|
GetItems()
Declaration
public abstract List<MyPhysicalInventoryItem> GetItems()
Returns
GetItemsCount()
Returns the number of items in the inventory. This needs to be overrided, otherwise it returns 0!
Declaration
public virtual int GetItemsCount()
Returns
| Type |
Description |
| System.Int32 |
int - number of items in inventory
|
IsSerialized()
Declaration
public override bool IsSerialized()
Returns
| Type |
Description |
| System.Boolean |
|
Overrides
ItemsCanBeAdded(MyFixedPoint, IMyInventoryItem)
Declaration
public abstract bool ItemsCanBeAdded(MyFixedPoint amount, IMyInventoryItem item)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
ItemsCanBeRemoved(MyFixedPoint, IMyInventoryItem)
Declaration
public abstract bool ItemsCanBeRemoved(MyFixedPoint amount, IMyInventoryItem item)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IterateInventory(Int32, Int32)
Search for inventory having given search index.
Aggregate inventory: Iterates through aggregate inventory until simple inventory with matching index is found.
Simple inventory: Returns itself if currentIndex == searchIndex.
Usage: searchIndex = index of inventory being searched, leave currentIndex = 0.
Declaration
public abstract MyInventoryBase IterateInventory(int searchIndex, int currentIndex = 0)
Parameters
| Type |
Name |
Description |
| System.Int32 |
searchIndex |
|
| System.Int32 |
currentIndex |
|
Returns
OnBeforeContentsChanged()
Declaration
public abstract void OnBeforeContentsChanged()
OnContentsAdded(MyPhysicalInventoryItem, MyFixedPoint)
Declaration
public abstract void OnContentsAdded(MyPhysicalInventoryItem item, MyFixedPoint amount)
Parameters
OnContentsChanged()
Declaration
public abstract void OnContentsChanged()
OnContentsRemoved(MyPhysicalInventoryItem, MyFixedPoint)
Declaration
public abstract void OnContentsRemoved(MyPhysicalInventoryItem item, MyFixedPoint amount)
Parameters
OnOwnerChanged()
Declaration
protected void OnOwnerChanged()
RaiseAfterModifyFinished()
Declaration
public void RaiseAfterModifyFinished()
RaiseBeforeContentsChanged()
Declaration
public void RaiseBeforeContentsChanged()
RaiseContentsAdded(MyPhysicalInventoryItem, MyFixedPoint)
Declaration
public void RaiseContentsAdded(MyPhysicalInventoryItem item, MyFixedPoint amount)
Parameters
RaiseContentsChanged()
Declaration
public void RaiseContentsChanged()
RaiseContentsRemoved(MyPhysicalInventoryItem, MyFixedPoint)
Declaration
public void RaiseContentsRemoved(MyPhysicalInventoryItem item, MyFixedPoint amount)
Parameters
RaiseInventoryContentChanged(MyPhysicalInventoryItem, MyFixedPoint)
Declaration
public void RaiseInventoryContentChanged(MyPhysicalInventoryItem item, MyFixedPoint amount)
Parameters
Remove(IMyInventoryItem, MyFixedPoint)
Declaration
public abstract bool Remove(IMyInventoryItem item, MyFixedPoint amount)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
RemoveItemsOfType(MyFixedPoint, MyDefinitionId, MyItemFlags, Boolean)
Remove items of a given amount and definition
Declaration
public abstract MyFixedPoint RemoveItemsOfType(MyFixedPoint amount, MyDefinitionId contentId, MyItemFlags flags, bool spawn = false)
Parameters
| Type |
Name |
Description |
| VRage.MyFixedPoint |
amount |
amount ot remove
|
| MyDefinitionId |
contentId |
definition id of items to be removed
|
| MyItemFlags |
flags |
|
| System.Boolean |
spawn |
Set tru to spawn object in the world, after it was removed
|
Returns
| Type |
Description |
| VRage.MyFixedPoint |
Returns the actually removed amount
|
Serialize(Boolean)
Declaration
public override MyObjectBuilder_ComponentBase Serialize(bool copy = false)
Parameters
| Type |
Name |
Description |
| System.Boolean |
copy |
|
Returns
Overrides
ToString()
Declaration
public override string ToString()
Returns
| Type |
Description |
| System.String |
|
Events
AfterModifyFinished
Declaration
public event Action<MyInventoryBase> AfterModifyFinished
Event Type
BeforeContentsChanged
Declaration
public event Action<MyInventoryBase> BeforeContentsChanged
Event Type
ContentsAdded
Declaration
public event Action<MyPhysicalInventoryItem, MyFixedPoint> ContentsAdded
Event Type
ContentsChanged
Called when items were added or removed, or their amount has changed
Declaration
public event Action<MyInventoryBase> ContentsChanged
Event Type
ContentsRemoved
Declaration
public event Action<MyPhysicalInventoryItem, MyFixedPoint> ContentsRemoved
Event Type
InventoryContentChanged
Declaration
public event Action<MyInventoryBase, MyPhysicalInventoryItem, MyFixedPoint> InventoryContentChanged
Event Type
OwnerChanged
Called if this inventory changed its owner
Declaration
public event Action<MyInventoryBase, IMyComponentContainer> OwnerChanged
Event Type
| Type |
Description |
| System.Action<MyInventoryBase, VRage.Game.Components.Interfaces.IMyComponentContainer> |
|
Extension Methods