Show / Hide Table of Contents

Class MyInventoryBase

Inheritance
System.Object
MyComponentBase
MyEntityComponentBase
MyInventoryBase
MyInventory
Inherited Members
MyEntityComponentBase.OnAddedToContainer()
MyEntityComponentBase.OnBeforeRemovedFromContainer()
MyEntityComponentBase.Container
MyEntityComponentBase.Entity
MyEntityComponentBase.OnAfterAddedToContainer
MyEntityComponentBase.BeforeRemovedFromContainer
MyComponentBase.SetContainer(IMyComponentContainer)
MyComponentBase.GetAs<T>()
MyComponentBase.OnAddedToScene()
MyComponentBase.OnRemovedFromScene()
MyComponentBase.Init(MyComponentDefinitionBase)
MyComponentBase.RemoveExistingComponentOnNewInsert
MyComponentBase.ContainerBase
Namespace: VRage.Game.Entity
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
public bool CanPutItems
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
MyEntityComponentBase.AttachSyncToEntity

ComponentTypeDebugString

Declaration
public override string ComponentTypeDebugString { get; }
Property Value
Type Description
System.String
Overrides
MyEntityComponentBase.ComponentTypeDebugString

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
Type Description
MyStringHash

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
Type Name Description
IMyInventoryItem item
VRage.MyFixedPoint amount
Returns
Type Description
System.Boolean

AddItems(MyFixedPoint, MyObjectBuilder_Base)

Adds item to inventory

Declaration
public abstract bool AddItems(MyFixedPoint amount, MyObjectBuilder_Base objectBuilder)
Parameters
Type Name Description
VRage.MyFixedPoint amount
MyObjectBuilder_Base objectBuilder
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
Type Name Description
System.Collections.Generic.List<MyComponentChange> changes

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
Type Name Description
MyObjectBuilder_ComponentBase builder
Overrides
MyComponentBase.Deserialize(MyObjectBuilder_ComponentBase)

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
Type Name Description
MyDefinitionId contentId
MyItemFlags flags
System.Boolean substitute
Returns
Type Description
VRage.MyFixedPoint

GetItems()

Declaration
public abstract List<MyPhysicalInventoryItem> GetItems()
Returns
Type Description
System.Collections.Generic.List<MyPhysicalInventoryItem>

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
MyComponentBase.IsSerialized()

ItemsCanBeAdded(MyFixedPoint, IMyInventoryItem)

Declaration
public abstract bool ItemsCanBeAdded(MyFixedPoint amount, IMyInventoryItem item)
Parameters
Type Name Description
VRage.MyFixedPoint amount
IMyInventoryItem item
Returns
Type Description
System.Boolean

ItemsCanBeRemoved(MyFixedPoint, IMyInventoryItem)

Declaration
public abstract bool ItemsCanBeRemoved(MyFixedPoint amount, IMyInventoryItem item)
Parameters
Type Name Description
VRage.MyFixedPoint amount
IMyInventoryItem item
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
Type Description
MyInventoryBase

OnBeforeContentsChanged()

Declaration
public abstract void OnBeforeContentsChanged()

OnContentsAdded(MyPhysicalInventoryItem, MyFixedPoint)

Declaration
public abstract void OnContentsAdded(MyPhysicalInventoryItem item, MyFixedPoint amount)
Parameters
Type Name Description
MyPhysicalInventoryItem item
VRage.MyFixedPoint amount

OnContentsChanged()

Declaration
public abstract void OnContentsChanged()

OnContentsRemoved(MyPhysicalInventoryItem, MyFixedPoint)

Declaration
public abstract void OnContentsRemoved(MyPhysicalInventoryItem item, MyFixedPoint amount)
Parameters
Type Name Description
MyPhysicalInventoryItem item
VRage.MyFixedPoint amount

OnOwnerChanged()

Declaration
protected void OnOwnerChanged()

RaiseBeforeContentsChanged()

Declaration
public void RaiseBeforeContentsChanged()

RaiseContentsAdded(MyPhysicalInventoryItem, MyFixedPoint)

Declaration
public void RaiseContentsAdded(MyPhysicalInventoryItem item, MyFixedPoint amount)
Parameters
Type Name Description
MyPhysicalInventoryItem item
VRage.MyFixedPoint amount

RaiseContentsChanged()

Declaration
public void RaiseContentsChanged()

RaiseContentsRemoved(MyPhysicalInventoryItem, MyFixedPoint)

Declaration
public void RaiseContentsRemoved(MyPhysicalInventoryItem item, MyFixedPoint amount)
Parameters
Type Name Description
MyPhysicalInventoryItem item
VRage.MyFixedPoint amount

RaiseInventoryContentChanged(MyPhysicalInventoryItem, MyFixedPoint)

Declaration
public void RaiseInventoryContentChanged(MyPhysicalInventoryItem item, MyFixedPoint amount)
Parameters
Type Name Description
MyPhysicalInventoryItem item
VRage.MyFixedPoint amount

Remove(IMyInventoryItem, MyFixedPoint)

Declaration
public abstract bool Remove(IMyInventoryItem item, MyFixedPoint amount)
Parameters
Type Name Description
IMyInventoryItem item
VRage.MyFixedPoint amount
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
Type Description
MyObjectBuilder_ComponentBase
Overrides
MyComponentBase.Serialize(Boolean)

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String

Events

BeforeContentsChanged

Declaration
public event Action<MyInventoryBase> BeforeContentsChanged
Event Type
Type Description
System.Action<MyInventoryBase>

ContentsAdded

Declaration
public event Action<MyPhysicalInventoryItem, MyFixedPoint> ContentsAdded
Event Type
Type Description
System.Action<MyPhysicalInventoryItem, VRage.MyFixedPoint>

ContentsChanged

Called when items were added or removed, or their amount has changed

Declaration
public event Action<MyInventoryBase> ContentsChanged
Event Type
Type Description
System.Action<MyInventoryBase>

ContentsRemoved

Declaration
public event Action<MyPhysicalInventoryItem, MyFixedPoint> ContentsRemoved
Event Type
Type Description
System.Action<MyPhysicalInventoryItem, VRage.MyFixedPoint>

InventoryContentChanged

Declaration
public event Action<MyInventoryBase, MyPhysicalInventoryItem, MyFixedPoint> InventoryContentChanged
Event Type
Type Description
System.Action<MyInventoryBase, MyPhysicalInventoryItem, VRage.MyFixedPoint>

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

MyEntityContainerEventExtensions.RegisterForEntityEvent(MyEntityComponentBase, MyStringHash, MyEntityContainerEventExtensions.EntityEventHandler)
MyEntityContainerEventExtensions.RegisterForEntityEvent(MyEntityComponentBase, MyEntity, MyStringHash, MyEntityContainerEventExtensions.EntityEventHandler)
MyEntityContainerEventExtensions.UnregisterForEntityEvent(MyEntityComponentBase, MyEntity, MyStringHash)
MyEntityContainerEventExtensions.RaiseEntityEvent(MyEntityComponentBase, MyStringHash, MyEntityContainerEventExtensions.EntityEventParams)
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾