public static bool RecipesMatch(CraftingGrid CG, CraftingRecipe CR) { for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { if (CR.RecipeParts[x, y] == null) { if (CG.GetStack(x, y) == null) { continue; } else { return false; } } if(!CR.RecipeParts[x, y].Match(CG.GetStack(x, y))) { return false; } } } return true; }
private static void RegisterRecipes(GameWorld World) { Crafting.CraftingRecipe TestRecipe = new Crafting.CraftingRecipe(World); TestRecipe.Output = new ItemStack(Block.GetBlock(1000), 1); Crafting.CraftingRecipePart CRP1 = new Crafting.CraftingRecipePart(); CRP1.AddPart(new ItemStack(Block.GetBlock(1), 1)); TestRecipe.RecipeParts[0, 0] = CRP1; Crafting.CraftingRecipePart CRP2 = new Crafting.CraftingRecipePart(); CRP2.AddPart(new ItemStack(Block.GetBlock(1), 1)); TestRecipe.RecipeParts[0, 1] = CRP2; Crafting.CraftingRecipe.RegisterRecipe(TestRecipe); }
public void UpdateGrid() { bool Found = false; foreach (CraftingRecipe CR in CraftingRecipe.Recipes) { if (CraftingRecipe.RecipesMatch(this, CR)) { _MatchingRecipe = CR; Found = true; OutputSlot.ItemStack = new ItemStack(CR.Output.Item, CR.Output.Count); } } if (!Found) { _MatchingRecipe = null; OutputSlot.ItemStack = null; } }
public static void RemoveRecipe(CraftingRecipe Recipe) { CraftingRegistry.Remove(Recipe); }
public static void RegisterRecipe(CraftingRecipe Recipe) { CraftingRegistry.Add(Recipe); Logger.Write("Recipe for item id " + Recipe.Output.Item.Id + " added to CraftingRegistry"); }