public override async Task OnActivateAsync()
        {
            var file = _fileProvider.GetFileInfo(_recipesFileName);

            var recipeLoader = new CraftingRecipeLoader();

            using (var sr = new StreamReader(file.CreateReadStream()))
                await recipeLoader.LoadRecipes(sr);
            _recipeMatcher = new CraftingRecipeMatcher(recipeLoader.Recipes);
        }
Esempio n. 2
0
        public async Task TestCraftingRecipeLoader()
        {
            var loader = new CraftingRecipeLoader();

            using (var sr = new StreamReader(File.OpenRead(Path.Combine(RootDir, "crafting.txt"))))
            {
                await loader.LoadRecipes(sr);
            }

            var recipes = loader.Recipes;

            Assert.Equal(13, recipes.Count);
        }
Esempio n. 3
0
        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));
        }