Ejemplo n.º 1
0
        // Showcase RecipeFinder and RecipeEditor
        // With these classes, you can find and edit recipes
        public static void ExampleRecipeEditing(Mod mod)
        {
            // In the following example, we find recipes that uses a chain as ingredient and then we remove that ingredient from the recipe.
            RecipeFinder finder = new RecipeFinder();           // make a new RecipeFinder

            finder.AddIngredient(ItemID.Chain);                 // add Chain (with a stack of 1) to the finder

            foreach (Recipe recipe in finder.SearchRecipes())   // loop every recipe found by the finder
            {
                RecipeEditor editor = new RecipeEditor(recipe); // for the currently looped recipe, make a new RecipeEditor
                editor.DeleteIngredient(ItemID.Chain);          // delete the Chain ingredient.
            }

            // The following is a more precise example, finding an exact recipe and deleting it if possible.
            finder = new RecipeFinder();                             // make a new RecipeFinder
            finder.AddRecipeGroup("IronBar");                        // add a new recipe group, in this case the vanilla one for iron or lead bars.
            finder.AddTile(TileID.Anvils);                           // add a required tile, any anvil
            finder.SetResult(ItemID.Chain, 10);                      // set the result to be 10 chains
            Recipe exactRecipe = finder.FindExactRecipe();           // try to find the exact recipe matching our criteria

            bool isRecipeFound = exactRecipe != null;                // if our recipe is not null, it means we found the exact recipe

            if (isRecipeFound)                                       // since our recipe is found, we can continue
            {
                RecipeEditor editor = new RecipeEditor(exactRecipe); // for our recipe, make a new RecipeEditor
                editor.DeleteRecipe();                               // delete the recipe
            }
        }
        public static void TestRecipeEditor(Mod mod)
        {
            RecipeFinder finder = new RecipeFinder();

            finder.AddIngredient(ItemID.Chain);
            foreach (Recipe recipe in finder.SearchRecipes())
            {
                RecipeEditor editor = new RecipeEditor(recipe);
                editor.DeleteIngredient(ItemID.Chain);
            }

            finder = new RecipeFinder();
            finder.AddRecipeGroup("IronBar");
            finder.AddTile(TileID.Anvils);
            finder.SetResult(ItemID.Chain, 10);
            Recipe recipe2 = finder.FindExactRecipe();

            if (recipe2 != null)
            {
                RecipeEditor editor = new RecipeEditor(recipe2);
                editor.DeleteRecipe();
            }
        }