Exemple #1
0
        /// <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;
        }
Exemple #2
0
        /// <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;
        }
Exemple #3
0
 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
     });