////////////////

        /// <summary>
        /// Gets available recipes of a given set of ingredient items for a given player.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="ingredients"></param>
        /// <returns></returns>
        public static IList <int> GetAvailableRecipesOfIngredients(Player player, IEnumerable <Item> ingredients)
        {
            int[] _;
            IDictionary <int, int> __;
            IList <int>            addedRecipeIndexes = new List <int>();
            ISet <int>             possibleRecipeIdxs = new HashSet <int>();

            foreach (Item ingredient in ingredients)
            {
                IEnumerable <int> ingredientRecipeIdxs = RecipeFinderHelpers.GetRecipeIndexesOfItem(ingredient.netID);

                foreach (int recipeIdx in ingredientRecipeIdxs)
                {
                    possibleRecipeIdxs.Add(recipeIdx);
                }
            }

            foreach (int recipeIdx in possibleRecipeIdxs)
            {
                Recipe recipe = Main.recipe[recipeIdx];
                if (recipe.createItem.type == 0)
                {
                    continue;
                }                                                               // Just in case?

                if (RecipeHelpers.GetRecipeFailReasons(player, recipe, out _, out __, ingredients) == 0)
                {
                    addedRecipeIndexes.Add(recipeIdx);
                }
            }

            return(addedRecipeIndexes);
        }
 /// <summary>
 /// Gets each `Recipe` that crafts a given item.
 /// </summary>
 /// <param name="itemNetID"></param>
 /// <returns></returns>
 public static IList <Recipe> GetRecipesOfItem(int itemNetID)
 {
     return(RecipeFinderHelpers.GetRecipeIndexesOfItem(itemNetID)
            .Select(idx => Main.recipe[idx])
            .ToList());
 }
示例#3
0
 public static ISet <int> GetRecipeIndexesUsingIngredient(int itemNetID)
 {
     return(RecipeFinderHelpers.GetRecipeIndexesUsingIngredient(itemNetID));
 }
示例#4
0
 public static ISet <int> GetRecipeIndexesOfItem(int itemNetID)
 {
     return(RecipeFinderHelpers.GetRecipeIndexesOfItem(itemNetID));
 }
示例#5
0
 public static IList <Recipe> GetRecipesOfItem(int itemNetID)
 {
     return(RecipeFinderHelpers.GetRecipesOfItem(itemNetID));
 }