Class InventoryChangeSet
A collection of modifications we wish to perform on an inventory
Inheritance
System.Object
InventoryChangeSet
Implements
System.IDisposable
Assembly: Eco.Gameplay.dll
Syntax
public sealed class InventoryChangeSet : Object, IInventoryChangeSet, IAtomicAction, IDisposable, IGameActionPackChangeSet
Fields
AccessNeeded
Declaration
public AccessType AccessNeeded
Field Value
ChangedStacks
Declaration
public Dictionary<ItemStack, ChangedStack> ChangedStacks
Field Value
IgnoreRestrictions
Declaration
public bool IgnoreRestrictions
Field Value
Type |
Description |
System.Boolean |
|
InventoryAccessType
Declaration
public InventoryAccessType InventoryAccessType
Field Value
OnItemsMoved
Declaration
public Action<IEnumerable<Item>> OnItemsMoved
Field Value
Type |
Description |
System.Action<System.Collections.Generic.IEnumerable<Item>> |
|
StacktraceCreation
Declaration
public static ConcurrentDictionary<int, string> StacktraceCreation
Field Value
Type |
Description |
System.Collections.Concurrent.ConcurrentDictionary<System.Int32, System.String> |
|
Methods
AddItem(Item, Int32, Inventory)
Declaration
public void AddItem(Item item, int count = 1, Inventory inventory = null)
Parameters
Type |
Name |
Description |
Item |
item |
|
System.Int32 |
count |
|
Inventory |
inventory |
|
AddItemNonUnique(Type, Inventory)
Declaration
public void AddItemNonUnique(Type itemType, Inventory inventory = null)
Parameters
Type |
Name |
Description |
System.Type |
itemType |
|
Inventory |
inventory |
|
AddItemNonUnique<T>(Inventory)
Declaration
public void AddItemNonUnique<T>(Inventory inventory = null)
Parameters
Type Parameters
AddItems(IEnumerable<ItemStack>)
Declaration
public void AddItems(IEnumerable<ItemStack> stacks)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<ItemStack> |
stacks |
|
AddItemsNonUnique(Type, Int32, Inventory)
Declaration
public void AddItemsNonUnique(Type itemType, int quantity, Inventory inventory = null)
Parameters
Type |
Name |
Description |
System.Type |
itemType |
|
System.Int32 |
quantity |
|
Inventory |
inventory |
|
AddItemsNonUnique<T>(Int32, Inventory)
Declaration
public void AddItemsNonUnique<T>(int quantity, Inventory inventory = null)
Parameters
Type |
Name |
Description |
System.Int32 |
quantity |
|
Inventory |
inventory |
|
Type Parameters
Apply()
Declaration
Returns
ApplyInternal(Boolean, Boolean)
Declaration
public Result ApplyInternal(bool throwOnInvalid, bool consolidating = false)
Parameters
Type |
Name |
Description |
System.Boolean |
throwOnInvalid |
|
System.Boolean |
consolidating |
|
Returns
CanApplyNonDisposing()
Declaration
public Result CanApplyNonDisposing()
Returns
Clear(Inventory)
Declaration
public void Clear(Inventory inventory = null)
Parameters
ClearStack(ItemStack)
Declaration
public void ClearStack(ItemStack stack)
Parameters
DescribeWhatItAdds()
Return a comma-separated string of the recent items added to the inventory.
Declaration
public LocString DescribeWhatItAdds()
Returns
Dispose()
Declaration
Finalize()
Declaration
protected override void Finalize()
GameActionPackDispose()
Declaration
public void GameActionPackDispose()
GameActionPackPostEffect()
Declaration
public LocString GameActionPackPostEffect()
Returns
GameActionPackPretest()
Declaration
public Result GameActionPackPretest()
Returns
GetTargetInventory(Inventory)
Declaration
public Inventory GetTargetInventory(Inventory inventory = null)
Parameters
Returns
GetUser()
Declaration
Returns
HasInventory(Inventory)
Declaration
public bool HasInventory(Inventory inventory)
Parameters
Returns
Type |
Description |
System.Boolean |
|
MergeStack(ItemStack, Int32, Item, Boolean)
Merges stack
with newItem
changing its quantity by delta
.
Declaration
public void MergeStack(ItemStack stack, int delta, Item newItem, bool splittingStack)
Parameters
Type |
Name |
Description |
ItemStack |
stack |
|
System.Int32 |
delta |
|
Item |
newItem |
|
System.Boolean |
splittingStack |
|
ModifyStack(ItemStack, Int32)
Declaration
public void ModifyStack(ItemStack stack, int delta)
Parameters
Type |
Name |
Description |
ItemStack |
stack |
|
System.Int32 |
delta |
|
MoveAllItems(Inventory, Inventory, Boolean, Func<ItemStack, Boolean>)
Try to move all items from src to dst inventory with move result.
Declaration
public InventoryMoveResult MoveAllItems(Inventory source, Inventory destination, bool allowPartial, Func<ItemStack, bool> selector = null)
Parameters
Type |
Name |
Description |
Inventory |
source |
|
Inventory |
destination |
|
System.Boolean |
allowPartial |
|
System.Func<ItemStack, System.Boolean> |
selector |
|
Returns
MoveAllItems(Item, Int32, Inventory, Inventory, Boolean, Func<ItemStack, Boolean>)
Try to move all items from source to dst inventory with result.
Declaration
public ValResult<int> MoveAllItems(Item sourceItem, int quantity, Inventory source, Inventory destination, bool allowPartial, Func<ItemStack, bool> sourceStackPredicate = null)
Parameters
Type |
Name |
Description |
Item |
sourceItem |
|
System.Int32 |
quantity |
|
Inventory |
source |
|
Inventory |
destination |
|
System.Boolean |
allowPartial |
|
System.Func<ItemStack, System.Boolean> |
sourceStackPredicate |
|
Returns
MoveAsManyItemsAsPossible(Type, Int32, Inventory, Inventory, ItemStack, Func<ItemStack, Boolean>)
Declaration
public ValResult<int> MoveAsManyItemsAsPossible(Type itemType, int quantity, Inventory source, Inventory destination, ItemStack destinationStack, Func<ItemStack, bool> sourceStackPredicate = null)
Parameters
Type |
Name |
Description |
System.Type |
itemType |
|
System.Int32 |
quantity |
|
Inventory |
source |
|
Inventory |
destination |
|
ItemStack |
destinationStack |
|
System.Func<ItemStack, System.Boolean> |
sourceStackPredicate |
|
Returns
MoveItems(Item, Int32, Inventory, Inventory, Func<ItemStack, Boolean>)
Declaration
public void MoveItems(Item item, int quantity, Inventory source, Inventory destination, Func<ItemStack, bool> sourceStackPredicate = null)
Parameters
MoveItems<TKey>(Item, Int32, Inventory, Inventory, Func<ItemStack, Boolean>, Func<ItemStack, TKey>)
Moves items with an optional source stack order, ordered by a given key
Declaration
public void MoveItems<TKey>(Item item, int quantity, Inventory source, Inventory destination, Func<ItemStack, bool> sourceStackPredicate = null, Func<ItemStack, TKey> sourceStackOrder = null)
Parameters
Type Parameters
MoveItemsNonUnique(Type, Int32, Inventory, Inventory)
Declaration
public void MoveItemsNonUnique(Type itemType, int quantity, Inventory source, Inventory destination)
Parameters
Type |
Name |
Description |
System.Type |
itemType |
|
System.Int32 |
quantity |
|
Inventory |
source |
|
Inventory |
destination |
|
MoveItemsNonUnique<TKey>(Type, Int32, Inventory, Inventory, Func<ItemStack, Boolean>, Func<ItemStack, TKey>)
Declaration
public void MoveItemsNonUnique<TKey>(Type itemType, int quantity, Inventory source, Inventory destination, Func<ItemStack, bool> sourceStackPredicate = null, Func<ItemStack, TKey> sourceStackOrder = null)
Parameters
Type |
Name |
Description |
System.Type |
itemType |
|
System.Int32 |
quantity |
|
Inventory |
source |
|
Inventory |
destination |
|
System.Func<ItemStack, System.Boolean> |
sourceStackPredicate |
|
System.Func<ItemStack, TKey> |
sourceStackOrder |
|
Type Parameters
MoveStacks(ItemStack, ItemStack, Int32)
Declaration
public void MoveStacks(ItemStack source, ItemStack destination, int requestedQuantity)
Parameters
Type |
Name |
Description |
ItemStack |
source |
|
ItemStack |
destination |
|
System.Int32 |
requestedQuantity |
|
New(Inventory, User)
Declaration
public static InventoryChangeSet New(Inventory inventory, User user = null)
Parameters
Returns
New(IEnumerable<Inventory>, User)
Declaration
public static InventoryChangeSet New(IEnumerable<Inventory> inventories, User user = null)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<Inventory> |
inventories |
|
User |
user |
|
Returns
Declaration
public Result PerformWithActionManager()
Returns
RemoveAsMuchAsPossible(ItemRepresentation, Int32)
Tries to remove as much as possible representation
up to requested
. Returns in order of least
durability first, if there is durability.
Declaration
public List<(Item, int)> RemoveAsMuchAsPossible(ItemRepresentation representation, int requested)
Parameters
Returns
Type |
Description |
System.Collections.Generic.List<System.ValueTuple<Item, System.Int32>> |
Returns all removed items with count.
|
RemoveItemByType(Type, Inventory)
Declaration
public void RemoveItemByType(Type itemType, Inventory inventory = null)
Parameters
Type |
Name |
Description |
System.Type |
itemType |
|
Inventory |
inventory |
|
RemoveItemByType<T>(Inventory)
Declaration
public void RemoveItemByType<T>(Inventory inventory = null)
Parameters
Type Parameters
RemoveItemsByType(Type, Int32, Inventory)
Declaration
public void RemoveItemsByType(Type itemType, int quantity, Inventory inventory = null)
Parameters
Type |
Name |
Description |
System.Type |
itemType |
|
System.Int32 |
quantity |
|
Inventory |
inventory |
|
RemoveItemsByType<T>(Int32, Inventory)
Declaration
public void RemoveItemsByType<T>(int quantity, Inventory inventory = null)
Parameters
Type |
Name |
Description |
System.Int32 |
quantity |
|
Inventory |
inventory |
|
Type Parameters
RemoveItemsUnique(Item, Int32, Inventory)
Declaration
public int RemoveItemsUnique(Item matchesItem, int quantity, Inventory inventory)
Parameters
Type |
Name |
Description |
Item |
matchesItem |
|
System.Int32 |
quantity |
|
Inventory |
inventory |
|
Returns
Type |
Description |
System.Int32 |
|
TryApply()
Declaration
Returns
Implements
System.IDisposable
Extension Methods