/// <summary>Create and return a new InventoryItem from a GameItem, with optional count.</summary> public static InventoryItem Create(IGameItem item, uint count = 0) { InventoryItem stack = item.CreateInventoryItem(); stack.count = count; return(stack); }
/// <summary>Try and store one or more IGameItems into the inventory.</summary> /// See <see cref="InventorySpace.Store(InventoryItem)"/> for more details. public InventoryResult Store(IGameItem item, uint count = 1) { InventoryItem toStore = item.CreateInventoryItem(); toStore.count = count; return(Store(toStore)); }
/// <summary> /// Try and take the specified number of items from a specific inventory space. /// </summary> /// <returns>An InventoryItem, with number of items taken (0 if none).</returns> public InventoryItem TakeFrom(string name, IGameItem item, uint count = 1) { InventorySpace space = FindSpaceByName(name); if (space != null) { return(space.Take(item, count)); } else { return(item.CreateInventoryItem()); /* Creates empty inventory item. */ } }
/// <summary> /// Try and take the specified number of items from the Inventories, starting /// with the main inventory, then searching all others until we got enough /// items, or we run out of inventories. /// </summary> /// <returns>An inventory item with the number of items taken.</returns> public InventoryItem Take(IGameItem item, uint count = 1) { InventoryItem ret = item.CreateInventoryItem(); foreach (InventorySpace space in stores) { space.Take(ret, count - ret.count); if (ret.count >= count) { break; } } return(ret); }
/// See <see cref="InventorySpace.Take(InventoryItem, uint)"> public InventoryItem Take(IGameItem item, uint count = 1) { InventoryItem newItem = item.CreateInventoryItem(); return(Take(newItem, count)); }