From 9f9c74de8d4e620ef19bb9580bf2d2c60069022d Mon Sep 17 00:00:00 2001 From: safronov Date: Thu, 29 Oct 2020 20:13:18 +0300 Subject: [PATCH] Allow beacon customization for buildings that have no module slots --- YAFC/Widgets/ObjectTooltip.cs | 2 +- .../ProductionTable/ModuleCustomisationScreen.cs | 13 ++++++++++--- .../ProductionTable/ProductionTableView.cs | 4 ++-- YAFCmodel/Model/RecipeParameters.cs | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/YAFC/Widgets/ObjectTooltip.cs b/YAFC/Widgets/ObjectTooltip.cs index 71fcb1f8..a09b959f 100644 --- a/YAFC/Widgets/ObjectTooltip.cs +++ b/YAFC/Widgets/ObjectTooltip.cs @@ -189,7 +189,7 @@ private void BuildEntity(Entity entity, ImGui gui) gui.BuildText(DataUtils.FormatAmount(entity.craftingSpeed, UnitOfMeasure.Percent, "Crafting speed: ")); if (entity.productivity != 0f) gui.BuildText(DataUtils.FormatAmount(entity.productivity, UnitOfMeasure.Percent, "Crafting productivity: ")); - if (entity.moduleSlots > 0) + if (entity.allowedEffects != AllowedEffects.None) { gui.BuildText("Module slots: " + entity.moduleSlots); if (entity.allowedEffects != AllowedEffects.All) diff --git a/YAFC/Workspace/ProductionTable/ModuleCustomisationScreen.cs b/YAFC/Workspace/ProductionTable/ModuleCustomisationScreen.cs index 3c31b625..48339215 100644 --- a/YAFC/Workspace/ProductionTable/ModuleCustomisationScreen.cs +++ b/YAFC/Workspace/ProductionTable/ModuleCustomisationScreen.cs @@ -31,9 +31,16 @@ public override void Build(ImGui gui) else { var effects = new ModuleEffects(); - gui.BuildText("Internal modules:", Font.subheader); - gui.BuildText("Leave zero amount to fill the remainings slots"); - DrawRecipeModules(gui, null, ref effects); + if (recipe.entity?.moduleSlots > 0) + { + gui.BuildText("Internal modules:", Font.subheader); + gui.BuildText("Leave zero amount to fill the remainings slots"); + DrawRecipeModules(gui, null, ref effects); + } + else + { + gui.BuildText("This building doesn't have module slots, but can be affected by beacons"); + } gui.BuildText("Beacon modules:", Font.subheader); if (recipe.modules.beacon == null) { diff --git a/YAFC/Workspace/ProductionTable/ProductionTableView.cs b/YAFC/Workspace/ProductionTable/ProductionTableView.cs index 132121ba..6347a907 100644 --- a/YAFC/Workspace/ProductionTable/ProductionTableView.cs +++ b/YAFC/Workspace/ProductionTable/ProductionTableView.cs @@ -499,7 +499,7 @@ private void ShowModuleDropDown(ImGui gui, RecipeRow recipe) recipe.RecordUndo().modules = JsonUtils.LoadFromJson(ModuleCustomisationScreen.copiedModuleSettings, recipe, recipe.modules); } } - else if (recipe.modules != null && (recipe.modules.list.Count > 1 || recipe.modules.beacon != null)) + else if (recipe.entity?.moduleSlots == 0 || recipe.modules != null && (recipe.modules.list.Count > 1 || recipe.modules.beacon != null)) { ModuleCustomisationScreen.Show(recipe); } @@ -572,7 +572,7 @@ private void BuildRecipeModules(ImGui gui, RecipeRow recipe) return; using (var grid = gui.EnterInlineGrid(3f)) { - if (recipe.entity != null && recipe.entity.moduleSlots > 0) + if (recipe.entity != null && recipe.entity.allowedEffects != AllowedEffects.None) { if (recipe.parameters.modules.modules == null || recipe.parameters.modules.modules.Length == 0) { diff --git a/YAFCmodel/Model/RecipeParameters.cs b/YAFCmodel/Model/RecipeParameters.cs index 70886901..b53fa9dd 100644 --- a/YAFCmodel/Model/RecipeParameters.cs +++ b/YAFCmodel/Model/RecipeParameters.cs @@ -151,7 +151,7 @@ public void CalculateParameters(Recipe recipe, Entity entity, Goods fuel, IModul warningFlags |= WarningFlags.AssumesNauvisSolarRatio; modules = default; - if (moduleFiller != null && recipe.modules.Length > 0 && entity.moduleSlots > 0 && recipe.IsAutomatable()) + if (moduleFiller != null && recipe.modules.Length > 0 && entity.allowedEffects != AllowedEffects.None && recipe.IsAutomatable()) { moduleFiller.GetModulesInfo(this, recipe, entity, fuel, ref activeEffects, ref modules); productivity += activeEffects.productivity;