Space Engineers
Public Member Functions | Static Public Member Functions | Properties | Events | List of all members
Sandbox.Game.Entities.Inventory.MyInventoryAggregate Class Reference

This class implements basic functionality for the interface IMyInventoryAggregate. Use it as base class only if the basic functionality is enough. More...

Inheritance diagram for Sandbox.Game.Entities.Inventory.MyInventoryAggregate:
VRage.Game.Entity.MyInventoryBase VRage.Game.Components.IMyComponentAggregate VRage.Network.IMyEventProxy VRage.Game.Components.MyEntityComponentBase VRage.Network.IMyEventProxy VRage.Network.IMyEventOwner VRage.Game.Components.MyComponentBase VRage.Network.IMyEventOwner

Public Member Functions

 MyInventoryAggregate ()
 
 MyInventoryAggregate (string inventoryId)
 
void Init ()
 
void DetachCallbacks ()
 
override MyFixedPoint ComputeAmountThatFits (MyDefinitionId contentId, float volumeRemoved=0, float massRemoved=0)
 
override MyFixedPoint GetItemAmount (MyDefinitionId contentId, MyItemFlags flags=MyItemFlags.None, bool substitute=false)
 
override bool AddItems (MyFixedPoint amount, MyObjectBuilder_Base objectBuilder)
 Adds item to inventory More...
 
override MyFixedPoint RemoveItemsOfType (MyFixedPoint amount, MyDefinitionId contentId, MyItemFlags flags=MyItemFlags.None, bool spawn=false)
 Remove items of a given amount and definition More...
 
MyInventoryBase GetInventory (MyStringHash id)
 
void AfterComponentAdd (MyComponentBase component)
 
void BeforeComponentRemove (MyComponentBase component)
 
override MyObjectBuilder_ComponentBase Serialize (bool copy=false)
 
override void Deserialize (MyObjectBuilder_ComponentBase builder)
 
override void CountItems (Dictionary< MyDefinitionId, MyFixedPoint > itemCounts)
 
override void ApplyChanges (List< MyComponentChange > changes)
 
override bool ItemsCanBeAdded (MyFixedPoint amount, IMyInventoryItem item)
 
override bool ItemsCanBeRemoved (MyFixedPoint amount, IMyInventoryItem item)
 
override bool Add (IMyInventoryItem item, MyFixedPoint amount)
 
override bool Remove (IMyInventoryItem item, MyFixedPoint amount)
 
override List< MyPhysicalInventoryItemGetItems ()
 
override void OnContentsChanged ()
 
override void OnBeforeContentsChanged ()
 
override bool TransferItemsFrom (MyInventoryBase sourceInventory, IMyInventoryItem item, MyFixedPoint amount)
 Transfers safely given item from inventory given as parameter to this instance. More...
 
override void ConsumeItem (MyDefinitionId itemId, MyFixedPoint amount, long consumerEntityId=0)
 
override int GetInventoryCount ()
 Returns number of embedded inventories - this inventory can be aggregation of other inventories. More...
 
override MyInventoryBase IterateInventory (int searchIndex, int currentIndex)
 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...
 
- Public Member Functions inherited from VRage.Game.Entity.MyInventoryBase
 MyInventoryBase (string inventoryId)
 
override void Deserialize (MyObjectBuilder_ComponentBase builder)
 
override MyObjectBuilder_ComponentBase Serialize (bool copy=false)
 
override string ToString ()
 
virtual int GetItemsCount ()
 Returns the number of items in the inventory. This needs to be overrided, otherwise it returns 0! More...
 
override bool IsSerialized ()
 Tells the component container serializer whether this component should be saved More...
 
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)
 

Static Public Member Functions

static MyInventoryAggregate FixInputOutputInventories (MyInventoryAggregate inventoryAggregate, MyInventoryConstraint inputInventoryConstraint, MyInventoryConstraint outputInventoryConstraint)
 Naive looking for inventories with some items.. More...
 

Properties

override MyFixedPoint CurrentMass [get]
 
override MyFixedPoint MaxMass [get]
 
override MyFixedPoint CurrentVolume [get]
 
override MyFixedPoint MaxVolume [get]
 
override int MaxItemCount [get]
 
override float ForcedPriority [get, set]
 
int InventoryCount [get]
 Returns number of inventories of MyInventory type contained in this aggregate More...
 
MyAggregateComponentList ChildList [get]
 
- Properties inherited from VRage.Game.Entity.MyInventoryBase
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...
 
- Properties inherited from VRage.Game.Components.IMyComponentAggregate
MyAggregateComponentList ChildList [get]
 
MyComponentContainer ContainerBase [get]
 

Events

virtual Action< MyInventoryAggregate, MyInventoryBaseOnAfterComponentAdd
 
virtual Action< MyInventoryAggregate, MyInventoryBaseOnBeforeComponentRemove
 
Action< MyInventoryAggregate, int > OnInventoryCountChanged
 
- Events inherited from VRage.Game.Entity.MyInventoryBase
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
 

Additional Inherited Members

- Public Attributes inherited from VRage.Game.Entity.MyInventoryBase
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 inherited from VRage.Game.Entity.MyInventoryBase
void OnOwnerChanged ()
 

Detailed Description

This class implements basic functionality for the interface IMyInventoryAggregate. Use it as base class only if the basic functionality is enough.

Definition at line 27 of file MyInventoryAggregate.cs.

Constructor & Destructor Documentation

Sandbox.Game.Entities.Inventory.MyInventoryAggregate.MyInventoryAggregate ( )
inline

Definition at line 156 of file MyInventoryAggregate.cs.

Sandbox.Game.Entities.Inventory.MyInventoryAggregate.MyInventoryAggregate ( string  inventoryId)
inline

Definition at line 158 of file MyInventoryAggregate.cs.

Member Function Documentation

override bool Sandbox.Game.Entities.Inventory.MyInventoryAggregate.Add ( IMyInventoryItem  item,
MyFixedPoint  amount 
)
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 379 of file MyInventoryAggregate.cs.

override bool Sandbox.Game.Entities.Inventory.MyInventoryAggregate.AddItems ( MyFixedPoint  amount,
MyObjectBuilder_Base  objectBuilder 
)
inlinevirtual

Adds item to inventory

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

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 205 of file MyInventoryAggregate.cs.

void Sandbox.Game.Entities.Inventory.MyInventoryAggregate.AfterComponentAdd ( MyComponentBase  component)
inline
override void Sandbox.Game.Entities.Inventory.MyInventoryAggregate.ApplyChanges ( List< MyComponentChange changes)
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 350 of file MyInventoryAggregate.cs.

void Sandbox.Game.Entities.Inventory.MyInventoryAggregate.BeforeComponentRemove ( MyComponentBase  component)
inline
override MyFixedPoint Sandbox.Game.Entities.Inventory.MyInventoryAggregate.ComputeAmountThatFits ( MyDefinitionId  contentId,
float  volumeRemoved = 0,
float  massRemoved = 0 
)
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 185 of file MyInventoryAggregate.cs.

override void Sandbox.Game.Entities.Inventory.MyInventoryAggregate.ConsumeItem ( MyDefinitionId  itemId,
MyFixedPoint  amount,
long  consumerEntityId = 0 
)
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 525 of file MyInventoryAggregate.cs.

override void Sandbox.Game.Entities.Inventory.MyInventoryAggregate.CountItems ( Dictionary< MyDefinitionId, MyFixedPoint itemCounts)
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 342 of file MyInventoryAggregate.cs.

override void Sandbox.Game.Entities.Inventory.MyInventoryAggregate.Deserialize ( MyObjectBuilder_ComponentBase  builder)
inlinevirtual

Reimplemented from VRage.Game.Components.MyComponentBase.

Definition at line 325 of file MyInventoryAggregate.cs.

void Sandbox.Game.Entities.Inventory.MyInventoryAggregate.DetachCallbacks ( )
inline

Definition at line 170 of file MyInventoryAggregate.cs.

static MyInventoryAggregate Sandbox.Game.Entities.Inventory.MyInventoryAggregate.FixInputOutputInventories ( MyInventoryAggregate  inventoryAggregate,
MyInventoryConstraint  inputInventoryConstraint,
MyInventoryConstraint  outputInventoryConstraint 
)
inlinestatic

Naive looking for inventories with some items..

Definition at line 624 of file MyInventoryAggregate.cs.

MyInventoryBase Sandbox.Game.Entities.Inventory.MyInventoryAggregate.GetInventory ( MyStringHash  id)
inline

Definition at line 241 of file MyInventoryAggregate.cs.

override int Sandbox.Game.Entities.Inventory.MyInventoryAggregate.GetInventoryCount ( )
inlinevirtual

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.

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 535 of file MyInventoryAggregate.cs.

override MyFixedPoint Sandbox.Game.Entities.Inventory.MyInventoryAggregate.GetItemAmount ( MyDefinitionId  contentId,
MyItemFlags  flags = MyItemFlags.None,
bool  substitute = false 
)
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 195 of file MyInventoryAggregate.cs.

override List<MyPhysicalInventoryItem> Sandbox.Game.Entities.Inventory.MyInventoryAggregate.GetItems ( )
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 399 of file MyInventoryAggregate.cs.

void Sandbox.Game.Entities.Inventory.MyInventoryAggregate.Init ( )
inline

Definition at line 161 of file MyInventoryAggregate.cs.

override bool Sandbox.Game.Entities.Inventory.MyInventoryAggregate.ItemsCanBeAdded ( MyFixedPoint  amount,
IMyInventoryItem  item 
)
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 359 of file MyInventoryAggregate.cs.

override bool Sandbox.Game.Entities.Inventory.MyInventoryAggregate.ItemsCanBeRemoved ( MyFixedPoint  amount,
IMyInventoryItem  item 
)
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 369 of file MyInventoryAggregate.cs.

override MyInventoryBase Sandbox.Game.Entities.Inventory.MyInventoryAggregate.IterateInventory ( int  searchIndex,
int  currentIndex 
)
inlinevirtual

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.

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 547 of file MyInventoryAggregate.cs.

override void Sandbox.Game.Entities.Inventory.MyInventoryAggregate.OnBeforeContentsChanged ( )
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 418 of file MyInventoryAggregate.cs.

override void Sandbox.Game.Entities.Inventory.MyInventoryAggregate.OnContentsChanged ( )
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 409 of file MyInventoryAggregate.cs.

override bool Sandbox.Game.Entities.Inventory.MyInventoryAggregate.Remove ( IMyInventoryItem  item,
MyFixedPoint  amount 
)
inlinevirtual

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 389 of file MyInventoryAggregate.cs.

override MyFixedPoint Sandbox.Game.Entities.Inventory.MyInventoryAggregate.RemoveItemsOfType ( MyFixedPoint  amount,
MyDefinitionId  contentId,
MyItemFlags  flags = MyItemFlags.None,
bool  spawn = false 
)
inlinevirtual

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

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 231 of file MyInventoryAggregate.cs.

override MyObjectBuilder_ComponentBase Sandbox.Game.Entities.Inventory.MyInventoryAggregate.Serialize ( bool  copy = false)
inlinevirtual

Reimplemented from VRage.Game.Components.MyComponentBase.

Definition at line 306 of file MyInventoryAggregate.cs.

override bool Sandbox.Game.Entities.Inventory.MyInventoryAggregate.TransferItemsFrom ( MyInventoryBase  sourceInventory,
IMyInventoryItem  item,
MyFixedPoint  amount 
)
inlinevirtual

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

Returns
true if items were succesfully transfered, otherwise, false

Implements VRage.Game.Entity.MyInventoryBase.

Definition at line 427 of file MyInventoryAggregate.cs.

Property Documentation

MyAggregateComponentList Sandbox.Game.Entities.Inventory.MyInventoryAggregate.ChildList
get

Definition at line 252 of file MyInventoryAggregate.cs.

override MyFixedPoint Sandbox.Game.Entities.Inventory.MyInventoryAggregate.CurrentMass
get

Definition at line 38 of file MyInventoryAggregate.cs.

override MyFixedPoint Sandbox.Game.Entities.Inventory.MyInventoryAggregate.CurrentVolume
get

Definition at line 64 of file MyInventoryAggregate.cs.

override float Sandbox.Game.Entities.Inventory.MyInventoryAggregate.ForcedPriority
getset

Definition at line 112 of file MyInventoryAggregate.cs.

int Sandbox.Game.Entities.Inventory.MyInventoryAggregate.InventoryCount
get

Returns number of inventories of MyInventory type contained in this aggregate

Definition at line 132 of file MyInventoryAggregate.cs.

override int Sandbox.Game.Entities.Inventory.MyInventoryAggregate.MaxItemCount
get

Definition at line 90 of file MyInventoryAggregate.cs.

override MyFixedPoint Sandbox.Game.Entities.Inventory.MyInventoryAggregate.MaxMass
get

Definition at line 51 of file MyInventoryAggregate.cs.

override MyFixedPoint Sandbox.Game.Entities.Inventory.MyInventoryAggregate.MaxVolume
get

Definition at line 77 of file MyInventoryAggregate.cs.

Event Documentation

virtual Action<MyInventoryAggregate, MyInventoryBase> Sandbox.Game.Entities.Inventory.MyInventoryAggregate.OnAfterComponentAdd

Definition at line 30 of file MyInventoryAggregate.cs.

virtual Action<MyInventoryAggregate, MyInventoryBase> Sandbox.Game.Entities.Inventory.MyInventoryAggregate.OnBeforeComponentRemove

Definition at line 31 of file MyInventoryAggregate.cs.

Action<MyInventoryAggregate, int> Sandbox.Game.Entities.Inventory.MyInventoryAggregate.OnInventoryCountChanged

Definition at line 126 of file MyInventoryAggregate.cs.


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