//////////////// public static ISet <int> GetAvailableRecipesOfIngredients(Player player, IEnumerable <Item> ingredients) { int[] _; IDictionary <int, int> __; ISet <int> addedRecipeIdxs = new HashSet <int>(); ISet <int> possibleRecipeIdxs = new HashSet <int>(); // Find all potential recipes of each individual ingredient foreach (Item ingredient in ingredients) { IEnumerable <int> ingredientRecipeIdxs = RecipeIdentityHelpers.GetRecipeIndexesUsingIngredient(ingredient.netID); possibleRecipeIdxs.UnionWith(ingredientRecipeIdxs); } // Filter potential recipes list to actual recipes only foreach (int recipeIdx in possibleRecipeIdxs) { Recipe recipe = Main.recipe[recipeIdx]; if (recipe == null || recipe.createItem.type == 0) { continue; } // Just in case? if (RecipeHelpers.GetRecipeFailReasons(player, recipe, out _, out __, ingredients) == 0) { addedRecipeIdxs.Add(recipeIdx); } } return(addedRecipeIdxs); }
//////////////// internal static void AwaitCraft(Player player, int recipeIdx) { var mymod = ModHelpersMod.Instance; if (mymod.RecipeHack.IngredientOutsources.Count == 0) { return; } int[] _; Recipe recipe = Main.recipe[recipeIdx]; IDictionary <int, int> missingItemTypesStacks; if (RecipeHelpers.GetRecipeFailReasons(Main.LocalPlayer, recipe, out _, out missingItemTypesStacks) != 0) { RecipeHack.AwaitingRecipeIdx = recipeIdx; RecipeHack.AwaitingRecipeMissingIngredients = missingItemTypesStacks; } else { RecipeHack.AwaitingRecipeIdx = -1; RecipeHack.AwaitingRecipeMissingIngredients = null; } }