public async Task TestCraftingRecipeMatcher() { var loader = new CraftingRecipeLoader(); using (var sr = new StreamReader(File.OpenRead(Path.Combine(RootDir, "crafting.txt")))) { await loader.LoadRecipes(sr); } var matcher = new CraftingRecipeMatcher(loader.Recipes); var recipe = matcher.FindRecipe(new Slot[, ] { { Slot.Empty, Slot.Empty, Slot.Empty }, { new Slot { BlockId = (short)BlockStates.Wood().Id, ItemCount = 1 }, Slot.Empty, Slot.Empty }, { Slot.Empty, Slot.Empty, Slot.Empty }, }); Assert.NotNull(recipe); Assert.Equal((short)BlockStates.WoodPlanks().Id, recipe.Result.BlockId); Assert.True(recipe.AfterTake.Cast <Slot>().All(o => o.IsEmpty)); }
public Task <FindCraftingRecipeResult> FindRecipe(Immutable <Slot[, ]> craftingGrid) { return(Task.FromResult(_recipeMatcher.FindRecipe(craftingGrid.Value))); }