private void DeserializeFlags(LuaTable table, RecipeOrTechnology recipe, bool forceDisable) { recipe.hidden = table.Get("hidden", true); if (forceDisable) { recipe.enabled = false; } else { recipe.enabled = table.Get("enabled", true); } }
private void BuildRecipe(RecipeOrTechnology recipe, ImGui gui) { BuildCommon(recipe, gui); using (gui.EnterGroup(contentPadding, RectAllocator.LeftRow)) { gui.BuildIcon(Icon.Time, 2f, SchemeColor.BackgroundText); gui.BuildText(DataUtils.FormatAmount(recipe.time, UnitOfMeasure.Second)); } using (gui.EnterGroup(contentPadding)) { foreach (var ingredient in recipe.ingredients) { BuildItem(gui, ingredient); } if (recipe is Recipe rec) { var waste = rec.RecipeWaste(); if (waste > 0.01f) { var wasteAmount = MathUtils.Round(waste * 100f); var wasteText = ". (Wasting " + wasteAmount + "% of YAFC cost)"; var color = wasteAmount < 90 ? SchemeColor.BackgroundText : SchemeColor.Error; if (recipe.products.Length == 1) { gui.BuildText("YAFC analysis: There are better recipes to create " + recipe.products[0].goods.locName + wasteText, wrap: true, color: color); } else if (recipe.products.Length > 0) { gui.BuildText("YAFC analysis: There are better recipes to create each of the products" + wasteText, wrap: true, color: color); } else { gui.BuildText("YAFC analysis: This recipe wastes useful products. Don't do this recipe.", wrap: true, color: color); } } } if (recipe.flags.HasFlags(RecipeFlags.UsesFluidTemperature)) { gui.BuildText("Uses fluid temperature"); } if (recipe.flags.HasFlags(RecipeFlags.UsesMiningProductivity)) { gui.BuildText("Uses mining productivity"); } if (recipe.flags.HasFlags(RecipeFlags.ScaleProductionWithPower)) { gui.BuildText("Production scaled with power"); } } if (recipe.products.Length > 0 && !(recipe.products.Length == 1 && recipe.products[0].IsSimple && recipe.products[0].goods is Item && recipe.products[0].amount == 1f)) { BuildSubHeader(gui, "Products"); using (gui.EnterGroup(contentPadding)) foreach (var product in recipe.products) { BuildItem(gui, product); } } BuildSubHeader(gui, "Made in"); using (gui.EnterGroup(contentPadding)) BuildIconRow(gui, recipe.crafters, 2); if (recipe.modules.Length > 0) { BuildSubHeader(gui, "Allowed modules"); using (gui.EnterGroup(contentPadding)) BuildIconRow(gui, recipe.modules, 1); } if (recipe is Recipe lockedRecipe && !lockedRecipe.enabled) { BuildSubHeader(gui, "Unlocked by"); using (gui.EnterGroup(contentPadding)) { if (lockedRecipe.technologyUnlock.Count > 2) { BuildIconRow(gui, lockedRecipe.technologyUnlock, 1); } else { foreach (var technology in lockedRecipe.technologyUnlock) { var ingredient = TechnologyScienceAnalysis.Instance.GetMaxTechnologyIngredient(technology); using (gui.EnterRow(allocator: RectAllocator.RightRow)) { gui.spacing = 0f; if (ingredient != null) { gui.BuildFactorioObjectIcon(ingredient.goods); gui.BuildText(DataUtils.FormatAmount(ingredient.amount, UnitOfMeasure.None)); } gui.allocator = RectAllocator.RemainigRow; gui.BuildFactorioObjectButtonWithText(technology); } } } } } }
private void BuildRecipe(RecipeOrTechnology recipe, ImGui gui) { BuildCommon(recipe, gui); using (gui.EnterGroup(contentPadding, RectAllocator.LeftRow)) { gui.BuildIcon(Icon.Time, 2f, SchemeColor.BackgroundText); gui.BuildText(recipe.time.ToString(CultureInfo.InvariantCulture)); } using (gui.EnterGroup(contentPadding)) { foreach (var ingredient in recipe.ingredients) { BuildItem(gui, ingredient); } if (recipe is Recipe rec) { var waste = rec.RecipeWaste(); if (waste > 0.01f) { var wasteAmount = MathUtils.Round(waste * 100f); var wasteText = ". (Wasting " + wasteAmount + "% of YAFC cost)"; var color = wasteAmount < 90 ? SchemeColor.BackgroundText : SchemeColor.Error; if (recipe.products.Length == 1) { gui.BuildText("YAFC analysis: There are better recipes to create " + recipe.products[0].goods.locName + wasteText, wrap: true, color: color); } else if (recipe.products.Length > 0) { gui.BuildText("YAFC analysis: There are better recipes to create each of the products" + wasteText, wrap: true, color: color); } else { gui.BuildText("YAFC analysis: This recipe wastes useful products. Don't do this recipe.", wrap: true, color: color); } } } if (recipe.flags.HasFlags(RecipeFlags.UsesFluidTemperature)) { gui.BuildText("Uses fluid temperature"); } if (recipe.flags.HasFlags(RecipeFlags.UsesMiningProductivity)) { gui.BuildText("Uses mining productivity"); } if (recipe.flags.HasFlags(RecipeFlags.ScaleProductionWithPower)) { gui.BuildText("Production scaled with power"); } } if (recipe.products.Length > 0 && !(recipe.products.Length == 1 && recipe.products[0].rawAmount == 1 && recipe.products[0].goods is Item && recipe.products[0].probability == 1f)) { BuildSubHeader(gui, "Products"); using (gui.EnterGroup(contentPadding)) foreach (var product in recipe.products) { BuildItem(gui, product); } } BuildSubHeader(gui, "Made in"); using (gui.EnterGroup(contentPadding)) BuildIconRow(gui, recipe.crafters, 2); if (recipe.modules.Length > 0) { BuildSubHeader(gui, "Allowed modules"); using (gui.EnterGroup(contentPadding)) BuildIconRow(gui, recipe.modules, 1); } if (!recipe.enabled) { BuildSubHeader(gui, "Unlocked by"); using (gui.EnterGroup(contentPadding)) { BuildIconRow(gui, recipe.technologyUnlock, 1); } } }