예제 #1
0
        ////////////////

        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 = RecipeIdentityHelpers.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);
        }
 public static bool Equals(Recipe recipe1, Recipe recipe2)
 {
     return(RecipeIdentityHelpers.Equals(recipe1, recipe2));
 }
 public static IList <Recipe> GetRecipesOfItem(int itemType)
 {
     return(RecipeIdentityHelpers.GetRecipesOfItem(itemType));
 }
예제 #4
0
 public static IList <Recipe> GetRecipesOfItem(int itemNetID)
 {
     return(RecipeIdentityHelpers.GetRecipeIndexesOfItem(itemNetID)
            .Select(idx => Main.recipe[idx])
            .ToList());
 }