Skip to content

Commit

Permalink
Allow beacon customization for buildings that have no module slots
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowTheAge committed Oct 29, 2020
1 parent 47c286f commit 9f9c74d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion YAFC/Widgets/ObjectTooltip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions YAFC/Workspace/ProductionTable/ModuleCustomisationScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions YAFC/Workspace/ProductionTable/ProductionTableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion YAFCmodel/Model/RecipeParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9f9c74d

Please sign in to comment.