/// <summary> /// Initializes a unique <see cref="ItemData"/> stack. /// </summary> /// <param name="id">The ID of the <see cref="Item"/> to store.</param> /// <param name="data">The unique data of the <see cref="Item"/> to store.</param> public ItemData(string id, UniqueItemData data) { if (!ItemHelper.IsUnique(id)) { throw new Exception("Incorrect item data initializer used."); } Id = id; TempId = KeyBuilder.Generate(5); Data = data; }
/// <summary> /// Initializes a non-unique <see cref="ItemData"/> stack. /// </summary> /// <param name="id">The ID of the <see cref="Item"/> to store.</param> /// <param name="stackCount">The stack count of the <see cref="Item"/> to store.</param> internal ItemData(string id, int stackCount) { if (ItemHelper.IsUnique(id)) { throw new Exception("Incorrect item data initializer used."); } Id = id; TempId = KeyBuilder.Generate(5); StackCount = stackCount; }
private static bool MeetsFilter(Item item, ItemFilter filter) { return(filter switch { ItemFilter.Ingredient => ItemHelper.IsIngredient(item), ItemFilter.Craftable => CraftHelper.CanCraft(item), ItemFilter.Sellable => ItemHelper.CanSell(item), ItemFilter.Buyable => ItemHelper.CanBuy(item), ItemFilter.Usable => item.Usage != null, ItemFilter.Tradable => ItemHelper.CanTrade(item), ItemFilter.Unique => ItemHelper.IsUnique(item), _ => false });