Skip to content

Commit

Permalink
fix(#400): Disabled technologies are disabled even if not hidden. (#411)
Browse files Browse the repository at this point in the history
This fixes #400 by ignoring (and removing) the hidden field in
technologies. It's still needed on recipes for weight calculations, but
not for anything else. (Yet, at least. If implemented, #399 will also
use the recipe hidden flag.)

A quick check does not reveal any new issues in Space Age or Omni.
  • Loading branch information
shpaass authored Feb 10, 2025
2 parents ea84e56 + 800bd6f commit d4e0707
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Yafc.Model/Analysis/DependencyNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public enum Flags {
ItemToPlace = 7,
TechnologyPrerequisites = 8 | RequireEverything | OneTimeInvestment,
IngredientVariant = 9,
Hidden = 10,
Disabled = 10,
Location = 11 | OneTimeInvestment,
}

Expand Down
6 changes: 3 additions & 3 deletions Yafc.Model/Data/DataClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public abstract class RecipeOrTechnology : FactorioObject {
public Goods? mainProduct { get; internal set; }
public float time { get; internal set; }
public bool enabled { get; internal set; }
public bool hidden { get; internal set; }
public RecipeFlags flags { get; internal set; }
public override string type => "Recipe";

Expand Down Expand Up @@ -184,6 +183,7 @@ public class Recipe : RecipeOrTechnology {
public Technology[] technologyUnlock { get; internal set; } = [];
public Dictionary<Technology, float> technologyProductivity { get; internal set; } = [];
public bool preserveProducts { get; internal set; }
public bool hidden { get; internal set; }

public bool HasIngredientVariants() {
foreach (var ingredient in ingredients) {
Expand Down Expand Up @@ -962,8 +962,8 @@ protected override List<DependencyNode> GetDependenciesHelper() {
nodes.Add(([Database.objectsByTypeName["Mechanics.launch." + triggerItem]], DependencyNode.Flags.Source));
}

if (hidden && !enabled) {
nodes.Add(([], DependencyNode.Flags.Hidden));
if (!enabled) {
nodes.Add(([], DependencyNode.Flags.Disabled));
}
return nodes;
}
Expand Down
10 changes: 3 additions & 7 deletions Yafc.Parser/Data/FactorioDataDeserializer_RecipeAndTechnology.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ private void DeserializeRecipe(LuaTable table, ErrorCollector errorCollector) {
}
}

private static void DeserializeFlags(LuaTable table, RecipeOrTechnology recipe) {
recipe.hidden = table.Get("hidden", false);
recipe.enabled = table.Get("enabled", true);
}

private void DeserializeTechnology(LuaTable table, ErrorCollector errorCollector) {
var technology = DeserializeCommon<Technology>(table, "technology");
LoadTechnologyData(technology, table, errorCollector);
Expand Down Expand Up @@ -130,7 +125,7 @@ private void LoadTechnologyData(Technology technology, LuaTable table, ErrorColl
errorCollector.Error($"Could not get requirement(s) to unlock {technology.name}.", ErrorSeverity.AnalysisWarning);
}

DeserializeFlags(table, technology);
technology.enabled = table.Get("enabled", true);
technology.time = unit.Get("time", 1f);
technology.count = unit.Get("count", 1000f);

Expand Down Expand Up @@ -374,6 +369,7 @@ private void LoadRecipeData(Recipe recipe, LuaTable table, ErrorCollector errorC
recipe.mainProduct = recipe.products[0]?.goods;
}

DeserializeFlags(table, recipe);
recipe.hidden = table.Get("hidden", false);
recipe.enabled = table.Get("enabled", true);
}
}
4 changes: 2 additions & 2 deletions Yafc/Widgets/ObjectTooltip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ private static void BuildTechnology(Technology technology, ImGui gui) {
BuildRecipe(technology, gui);
}

if (technology.hidden && !technology.enabled) {
if (!technology.enabled) {
using (gui.EnterGroup(contentPadding)) {
gui.BuildText("This technology is hidden from the list and cannot be researched.", TextBlockDisplayStyle.WrappedText);
gui.BuildText("This technology is disabled and cannot be researched.", TextBlockDisplayStyle.WrappedText);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Yafc/Windows/DependencyExplorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class DependencyExplorer : PseudoScreen {
{DependencyNode.Flags.TechnologyPrerequisites, ("Research", "There are no technology prerequisites")},
{DependencyNode.Flags.ItemToPlace, ("Item", "This entity cannot be placed")},
{DependencyNode.Flags.SourceEntity, ("Source", "This recipe requires another entity")},
{DependencyNode.Flags.Hidden, ("", "This technology is hidden")},
{DependencyNode.Flags.Disabled, ("", "This technology is disabled")},
{DependencyNode.Flags.Location, ("Location", "There are no locations that spawn this entity")},
};

Expand Down Expand Up @@ -77,10 +77,10 @@ private void DrawDependencies(ImGui gui) {
else {
string text = dependencyType.missingText;
if (Database.rootAccessible.Contains(current)) {
text += ", but it is inherently accessible";
text += ", but it is inherently accessible.";
}
else {
text += ", and it is inaccessible";
text += ", and it is inaccessible.";
}

gui.BuildText(text, TextBlockDisplayStyle.WrappedText);
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Date:
Fixes:
- When creating launch recipes, obey the rocket capacity, not the item stack size.
- Improve detection of special (e.g. barrelling, caging) recipes, especially with SA's recycling recipes.
- (regression) Py TURDs and other disabled techs were considered enabled if they were not also hidden.
----------------------------------------------------------------------------------------------------------------------
Version: 2.7.0
Date: January 27th 2025
Expand Down

0 comments on commit d4e0707

Please sign in to comment.