private void ShowRecipes(Inventory inventory) { var recipes = RecipeState.available_recipies(); var choices = new List <ListController <RecipeInfo> .ListElement>(); for (int i = 0; i < recipes.Count; i++) { string requirements_string = "Required:"; for (int j = 0; j < recipes[i].inputs.Length; j++) { if (j != 0) { requirements_string = $"{requirements_string},"; } requirements_string = $"{requirements_string} {recipes[i].inputs[j].amount} {recipes[i].inputs[j].info.name}"; } choices.Add(new ListController <RecipeInfo> .ListElement() { text = recipes[i].output.info.name, choosable = inventory.can_make(recipes[i]), description = requirements_string, image = recipes[i].output.info.image, value = recipes[i] }); } choices.Add(new ListController <RecipeInfo> .ListElement() { text = "Cancel", choosable = true, description = null, value = null, }); this.recipe_controller.ShowList(choices); }
public ItemRequirements(ItemInfo item) { this.base_item = item; this.providers = ResourceManager.Instance.those_providing(item).ToList(); this.recipe = RecipeState.available_recipies() .Find(x => x.output.info == item); }
public void ForwardBackwardRecipeConversionWithoutInformationLoss(DummyProductRecipe originalRecipe, RecipeClassification classification, RecipeState state, DummyProductType backupProductType, DummyWorkplan workplanInTargetRecipe, int testCaseCounter) { // Arrange // - Basic Workplan properties originalRecipe.Id = 42; originalRecipe.Name = "TestName"; originalRecipe.Revision = 1337; originalRecipe.Classification = classification; originalRecipe.State = state; // - Mock workplan requests if there could be a Workplan var originalWorkplanRecipe = originalRecipe as DummyProductWorkplanRecipe; if (originalWorkplanRecipe is not null) { _workplanManagementMock.Setup(wm => wm.LoadWorkplan(It.IsAny <long>())) .Returns((long id) => new DummyWorkplan() { Id = id }); } // - Create target object var targetDummyRecipe = (DummyProductRecipe)Activator.CreateInstance(originalRecipe.GetType()); targetDummyRecipe.Id = 42; if (originalWorkplanRecipe is not null) { ((DummyProductWorkplanRecipe)targetDummyRecipe).Workplan = workplanInTargetRecipe; } // - No change of classification on clones should be possible, thereby preset it if (originalRecipe.Classification.HasFlag(RecipeClassification.Clone)) { targetDummyRecipe.Classification = originalRecipe.Classification; } // Act var convertedModel = _productConverter.ConvertRecipe(originalRecipe); var recoveredOriginal = _productConverter.ConvertRecipeBack(convertedModel, targetDummyRecipe, backupProductType); // Assert // - Backup products are used for recipes without products if (originalRecipe.Product is null) { originalRecipe.Product = backupProductType; } Assert.AreEqual(originalRecipe, recoveredOriginal); // - If there is a workplan and it changed, reload it at backward conversion if (originalWorkplanRecipe?.Workplan is not null && originalWorkplanRecipe.Workplan.Id != workplanInTargetRecipe.Id) { _workplanManagementMock.Verify(wm => wm.LoadWorkplan(originalWorkplanRecipe.Workplan.Id), Times.Once); }
//void FixRecipeLayout(List<GameObject> ingredients) //{ //} void UpdateRecipeToState(Recipe recipe, RecipeState state) { recipe.state = state; UpdateRecipeToState(recipe); }