internal static void ConfirmCraft(Player player, Recipe recipe)
        {
            var mymod = ModHelpersMod.Instance;

            if (mymod.RecipeHack.IngredientOutsources.Count == 0)
            {
                return;
            }

            if (RecipeHack.AwaitingRecipeIdx == -1 || RecipeHack.AwaitingRecipeMissingIngredients == null)
            {
                return;
            }
            if (!RecipeIdentityHelpers.Equals(Main.recipe[RecipeHack.AwaitingRecipeIdx], recipe))
            {
                RecipeHack.AwaitingRecipeIdx = -1;
                RecipeHack.AwaitingRecipeMissingIngredients = null;
                return;
            }
            if (Main.mouseItem.IsNotTheSameAs(recipe.createItem))
            {
                RecipeHack.AwaitingRecipeIdx = -1;
                RecipeHack.AwaitingRecipeMissingIngredients = null;
                return;
            }

            IEnumerable <Item> outsourcedItems = RecipeHack.GetOutsourcedItems(player);

            ItemHelpers.ConsumeItems(RecipeHack.AwaitingRecipeMissingIngredients, outsourcedItems);

            RecipeHack.AwaitingRecipeIdx = -1;
            RecipeHack.AwaitingRecipeMissingIngredients = null;
        }
Пример #2
0
        ////////////////

        internal RecipeHack()
        {
            LoadHooks.AddPostModLoadHook(() => {
                for (int i = 0; i < Recipe.maxRecipes; i++)
                {
                    if (Main.recipe[i].createItem.type == 0)
                    {
                        break;
                    }

                    RecipeHack.BindRecipeItem(i);
                }
            });
        }
Пример #3
0
        private void UpdateRecipes()
        {
            IEnumerable <Item> ingredients   = RecipeHack.GetOutsourcedItems(Main.LocalPlayer);
            ISet <int>         recipeIndexes = RecipeHack.GetAvailableRecipesOfIngredients(Main.LocalPlayer, ingredients);

            for (int i = 0; i < Main.numAvailableRecipes; i++)
            {
                // Force-remove recipes that aren't within the current set
                if (!recipeIndexes.Contains(Main.availableRecipe[i]))
                {
                    while (RecipeHack.ForceRemoveRecipe(Main.availableRecipe[i]))
                    {
                    }
                }
                else
                {
                    recipeIndexes.Remove(Main.availableRecipe[i]);
                }
            }

            foreach (int idx in recipeIndexes)
            {
                RecipeHack.ForceAddRecipe(idx);
            }

            if (this.OldFocusRecipe >= 0)
            {
                int toIdx = Math.Min(this.OldFocusRecipe, Main.numAvailableRecipes);
                int shift = (Main.focusRecipe - toIdx) * 65;

                for (int i = 0; i < Main.numAvailableRecipes; i++)
                {
                    Main.availableRecipeY[i] += shift;
                }

                Main.focusRecipe = toIdx;
            }
        }