Space Engineers
Public Member Functions | Public Attributes | Protected Member Functions | Properties | Events | List of all members
VRage.Game.Entity.MyInventoryBase Class Referenceabstract
Inheritance diagram for VRage.Game.Entity.MyInventoryBase:
VRage.Game.Components.MyEntityComponentBase VRage.Network.IMyEventProxy VRage.Game.Components.MyComponentBase VRage.Network.IMyEventOwner Sandbox.Game.Entities.Inventory.MyInventoryAggregate Sandbox.Game.MyInventory

Public Member Functions

 MyInventoryBase (string inventoryId)
 
override void Deserialize (MyObjectBuilder_ComponentBase builder)
 
override MyObjectBuilder_ComponentBase Serialize (bool copy=false)
 
override string ToString ()
 
abstract MyFixedPoint ComputeAmountThatFits (MyDefinitionId contentId, float volumeRemoved=0, float massRemoved=0)
 
abstract MyFixedPoint GetItemAmount (MyDefinitionId contentId, MyItemFlags flags=MyItemFlags.None, bool substitute=false)
 
abstract bool ItemsCanBeAdded (MyFixedPoint amount, IMyInventoryItem item)
 
abstract bool ItemsCanBeRemoved (MyFixedPoint amount, IMyInventoryItem item)
 
abstract bool Add (IMyInventoryItem item, MyFixedPoint amount)
 
abstract bool Remove (IMyInventoryItem item, MyFixedPoint amount)
 
abstract void CountItems (Dictionary< MyDefinitionId, MyFixedPoint > itemCounts)
 
abstract void ApplyChanges (List< MyComponentChange > changes)
 
abstract List< MyPhysicalInventoryItemGetItems ()
 
abstract bool AddItems (MyFixedPoint amount, MyObjectBuilder_Base objectBuilder)
 Adds item to inventory More...
 
abstract MyFixedPoint RemoveItemsOfType (MyFixedPoint amount, MyDefinitionId contentId, MyItemFlags flags=MyItemFlags.None, bool spawn=false)
 Remove items of a given amount and definition More...
 
abstract bool TransferItemsFrom (MyInventoryBase sourceInventory, IMyInventoryItem item, MyFixedPoint amount)
 Transfers safely given item from inventory given as parameter to this instance. More...
 
abstract void OnContentsChanged ()
 
abstract void OnBeforeContentsChanged ()
 
virtual int GetItemsCount ()
 Returns the number of items in the inventory. This needs to be overrided, otherwise it returns 0! More...
 
abstract int GetInventoryCount ()
 Returns number of embedded inventories - this inventory can be aggregation of other inventories. More...
 
abstract MyInventoryBase IterateInventory (int searchIndex, int currentIndex=0)
 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. More...
 
override bool IsSerialized ()
 Tells the component container serializer whether this component should be saved More...
 
abstract void ConsumeItem (MyDefinitionId itemId, MyFixedPoint amount, long consumerEntityId=0)
 
void RaiseContentsChanged ()
 
void RaiseBeforeContentsChanged ()
 
- Public Member Functions inherited from VRage.Game.Components.MyEntityComponentBase
override void OnAddedToContainer ()
 Gets called after the container of this component changes More...
 
override void OnBeforeRemovedFromContainer ()
 Gets called before the removal of this component from a container More...
 
- Public Member Functions inherited from VRage.Game.Components.MyComponentBase
virtual void SetContainer (MyComponentContainer container)
 Sets the container of this component. Note that the component is not added to the container here! Therefore, use MyComponentContainer.Add(...) method and it will in turn call this method. Actually, you should seldom have the need to call this method yourself. More...
 
virtual T GetAs< T > ()
 
virtual void OnAddedToScene ()
 CH: TOOD: Be careful! This does not get called if the component is added to a container that is in the scene already! More...
 
virtual void OnRemovedFromScene ()
 CH: TOOD: Be careful! This does not get called if the component is removed from a container that is still in the scene! More...
 
virtual void Init (MyComponentDefinitionBase definition)
 

Public Attributes

bool RemoveEntityOnEmpty = false
 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. More...
 

Protected Member Functions

void OnOwnerChanged ()
 

Properties

MyStringHash InventoryId [get]
 This is for the purpose of identifying the inventory in aggregates (i.e. "Backpack", "LeftHand", ...) More...
 
abstract MyFixedPoint CurrentMass [get]
 
abstract MyFixedPoint MaxMass [get]
 
abstract int MaxItemCount [get]
 
abstract MyFixedPoint CurrentVolume [get]
 
abstract MyFixedPoint MaxVolume [get]
 
abstract float ForcedPriority [get, set]
 
override string ComponentTypeDebugString [get]
 
- Properties inherited from VRage.Game.Components.MyEntityComponentBase
MyEntityComponentContainer Container [get]
 
IMyEntity Entity [get]
 
abstract string ComponentTypeDebugString [get]
 Name of the base component type for debug purposes (e.g.: "Position") More...
 
- Properties inherited from VRage.Game.Components.MyComponentBase
MyComponentContainer ContainerBase [get]
 This cannot be named Container to not conflict with the definition of Container in MyEntityComponentBase. More...
 

Events

Action< MyInventoryBaseContentsChanged
 Called when items were added or removed, or their amount has changed More...
 
Action< MyInventoryBaseBeforeContentsChanged
 
Action< MyInventoryBase, MyComponentContainerOwnerChanged
 Called if this inventory changed its owner More...
 
- Events inherited from VRage.Game.Components.MyEntityComponentBase
static Action< MyEntityComponentBaseOnAfterAddedToContainer
 
Action< MyEntityComponentBaseBeforeRemovedFromContainer
 

Detailed Description

Definition at line 15 of file MyInventoryBase.cs.

Constructor & Destructor Documentation

VRage.Game.Entity.MyInventoryBase.MyInventoryBase ( string  inventoryId)
inline

Definition at line 49 of file MyInventoryBase.cs.

Member Function Documentation

abstract bool VRage.Game.Entity.MyInventoryBase.Add ( IMyInventoryItem  item,
MyFixedPoint  amount 
)
pure virtual
abstract bool VRage.Game.Entity.MyInventoryBase.AddItems ( MyFixedPoint  amount,
MyObjectBuilder_Base  objectBuilder 
)
pure virtual

Adds item to inventory

Parameters
amount
objectBuilder
index
Returns
true if items were added, false if items didn't fit

Implemented in Sandbox.Game.MyInventory, and Sandbox.Game.Entities.Inventory.MyInventoryAggregate.

abstract void VRage.Game.Entity.MyInventoryBase.ApplyChanges ( List< MyComponentChange changes)
pure virtual
abstract MyFixedPoint VRage.Game.Entity.MyInventoryBase.ComputeAmountThatFits ( MyDefinitionId  contentId,
float  volumeRemoved = 0,
float  massRemoved = 0 
)
pure virtual
abstract void VRage.Game.Entity.MyInventoryBase.ConsumeItem ( MyDefinitionId  itemId,
MyFixedPoint  amount,
long  consumerEntityId = 0 
)
pure virtual
abstract void VRage.Game.Entity.MyInventoryBase.CountItems ( Dictionary< MyDefinitionId, MyFixedPoint itemCounts)
pure virtual
override void VRage.Game.Entity.MyInventoryBase.Deserialize ( MyObjectBuilder_ComponentBase  builder)
inlinevirtual

Reimplemented from VRage.Game.Components.MyComponentBase.

Definition at line 54 of file MyInventoryBase.cs.

abstract int VRage.Game.Entity.MyInventoryBase.GetInventoryCount ( )
pure virtual

Returns number of embedded inventories - this inventory can be aggregation of other inventories.

Returns
Return one for simple inventory, different number when this instance is an aggregation.

Implemented in Sandbox.Game.MyInventory, and Sandbox.Game.Entities.Inventory.MyInventoryAggregate.

abstract MyFixedPoint VRage.Game.Entity.MyInventoryBase.GetItemAmount ( MyDefinitionId  contentId,
MyItemFlags  flags = MyItemFlags.None,
bool  substitute = false 
)
pure virtual
abstract List<MyPhysicalInventoryItem> VRage.Game.Entity.MyInventoryBase.GetItems ( )
pure virtual
virtual int VRage.Game.Entity.MyInventoryBase.GetItemsCount ( )
inlinevirtual

Returns the number of items in the inventory. This needs to be overrided, otherwise it returns 0!

Returns
int - number of items in inventory

Reimplemented in Sandbox.Game.MyInventory.

Definition at line 121 of file MyInventoryBase.cs.

override bool VRage.Game.Entity.MyInventoryBase.IsSerialized ( )
inlinevirtual

Tells the component container serializer whether this component should be saved

Returns

Reimplemented from VRage.Game.Components.MyComponentBase.

Definition at line 148 of file MyInventoryBase.cs.

abstract bool VRage.Game.Entity.MyInventoryBase.ItemsCanBeAdded ( MyFixedPoint  amount,
IMyInventoryItem  item 
)
pure virtual
abstract bool VRage.Game.Entity.MyInventoryBase.ItemsCanBeRemoved ( MyFixedPoint  amount,
IMyInventoryItem  item 
)
pure virtual
abstract MyInventoryBase VRage.Game.Entity.MyInventoryBase.IterateInventory ( int  searchIndex,
int  currentIndex = 0 
)
pure virtual

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.

Implemented in Sandbox.Game.MyInventory, and Sandbox.Game.Entities.Inventory.MyInventoryAggregate.

abstract void VRage.Game.Entity.MyInventoryBase.OnBeforeContentsChanged ( )
pure virtual
abstract void VRage.Game.Entity.MyInventoryBase.OnContentsChanged ( )
pure virtual
void VRage.Game.Entity.MyInventoryBase.OnOwnerChanged ( )
inlineprotected

Definition at line 141 of file MyInventoryBase.cs.

void VRage.Game.Entity.MyInventoryBase.RaiseBeforeContentsChanged ( )
inline

Definition at line 161 of file MyInventoryBase.cs.

void VRage.Game.Entity.MyInventoryBase.RaiseContentsChanged ( )
inline

Definition at line 155 of file MyInventoryBase.cs.

abstract bool VRage.Game.Entity.MyInventoryBase.Remove ( IMyInventoryItem  item,
MyFixedPoint  amount 
)
pure virtual
abstract MyFixedPoint VRage.Game.Entity.MyInventoryBase.RemoveItemsOfType ( MyFixedPoint  amount,
MyDefinitionId  contentId,
MyItemFlags  flags = MyItemFlags.None,
bool  spawn = false 
)
pure virtual

Remove items of a given amount and definition

Parameters
amountamount ot remove
contentIddefinition id of items to be removed
spawnSet tru to spawn object in the world, after it was removed
Returns
Returns the actually removed amount

Implemented in Sandbox.Game.MyInventory, and Sandbox.Game.Entities.Inventory.MyInventoryAggregate.

override MyObjectBuilder_ComponentBase VRage.Game.Entity.MyInventoryBase.Serialize ( bool  copy = false)
inlinevirtual

Reimplemented from VRage.Game.Components.MyComponentBase.

Definition at line 62 of file MyInventoryBase.cs.

override string VRage.Game.Entity.MyInventoryBase.ToString ( )
inline

Definition at line 70 of file MyInventoryBase.cs.

abstract bool VRage.Game.Entity.MyInventoryBase.TransferItemsFrom ( MyInventoryBase  sourceInventory,
IMyInventoryItem  item,
MyFixedPoint  amount 
)
pure virtual

Transfers safely given item from inventory given as parameter to this instance.

Returns
true if items were succesfully transfered, otherwise, false

Implemented in Sandbox.Game.MyInventory, and Sandbox.Game.Entities.Inventory.MyInventoryAggregate.

Member Data Documentation

bool VRage.Game.Entity.MyInventoryBase.RemoveEntityOnEmpty = false

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.

Definition at line 21 of file MyInventoryBase.cs.

Property Documentation

override string VRage.Game.Entity.MyInventoryBase.ComponentTypeDebugString
get

Definition at line 36 of file MyInventoryBase.cs.

abstract MyFixedPoint VRage.Game.Entity.MyInventoryBase.CurrentMass
get

Definition at line 28 of file MyInventoryBase.cs.

abstract MyFixedPoint VRage.Game.Entity.MyInventoryBase.CurrentVolume
get

Definition at line 32 of file MyInventoryBase.cs.

abstract float VRage.Game.Entity.MyInventoryBase.ForcedPriority
getset

Definition at line 35 of file MyInventoryBase.cs.

MyStringHash VRage.Game.Entity.MyInventoryBase.InventoryId
get

This is for the purpose of identifying the inventory in aggregates (i.e. "Backpack", "LeftHand", ...)

Definition at line 26 of file MyInventoryBase.cs.

abstract int VRage.Game.Entity.MyInventoryBase.MaxItemCount
get

Definition at line 30 of file MyInventoryBase.cs.

abstract MyFixedPoint VRage.Game.Entity.MyInventoryBase.MaxMass
get

Definition at line 29 of file MyInventoryBase.cs.

abstract MyFixedPoint VRage.Game.Entity.MyInventoryBase.MaxVolume
get

Definition at line 33 of file MyInventoryBase.cs.

Event Documentation

Action<MyInventoryBase> VRage.Game.Entity.MyInventoryBase.BeforeContentsChanged

Definition at line 42 of file MyInventoryBase.cs.

Action<MyInventoryBase> VRage.Game.Entity.MyInventoryBase.ContentsChanged

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

Definition at line 41 of file MyInventoryBase.cs.

Action<MyInventoryBase, MyComponentContainer> VRage.Game.Entity.MyInventoryBase.OwnerChanged

Called if this inventory changed its owner

Definition at line 47 of file MyInventoryBase.cs.


The documentation for this class was generated from the following file: