Skip to content

Commit

Permalink
fix(icons): Use icons that exist in 2.0.33 for science&launches. (#402)
Browse files Browse the repository at this point in the history
I checked that the rocket launch slot image also exists in 2.0.32, but I
don't have earlier 2.0 versions readily available. If there's interest
in supporting both 1.1 and 2.0, I'll need to be more creative about
selecting the launch slot image and creating the science/research-unit
item.
  • Loading branch information
DaleStan authored Feb 2, 2025
2 parents 842bdb2 + f98dd51 commit b6cbe02
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
16 changes: 7 additions & 9 deletions Yafc.Model/Data/DataClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,13 @@ public override bool HasSpentFuel([NotNullWhen(true)] out Item? spent) {
spent = fuelResult;
return spent != null;
}

public override DependencyNode GetDependencies() {
if (this == Database.science) {
return (Database.technologies.all, DependencyNode.Flags.Source);
}
return base.GetDependencies();
}
}

public class Module : Item {
Expand Down Expand Up @@ -464,20 +471,11 @@ public class Location : FactorioObject {
public class Special : Goods {
internal string? virtualSignal { get; set; }
internal bool power;
internal bool isResearch;
internal bool isVoid;
public override bool isPower => power;
public override string type => isPower ? "Power" : "Special";
public override UnitOfMeasure flowUnitOfMeasure => isVoid ? UnitOfMeasure.None : isPower ? UnitOfMeasure.Megawatt : UnitOfMeasure.PerSecond;
internal override FactorioObjectSortOrder sortingOrder => FactorioObjectSortOrder.SpecialGoods;
public override DependencyNode GetDependencies() {
if (isResearch) {
return (Database.technologies.all, DependencyNode.Flags.Source);
}
else {
return base.GetDependencies();
}
}
}

[Flags]
Expand Down
2 changes: 1 addition & 1 deletion Yafc.Model/Data/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class Database {
public static Dictionary<string, FactorioObject> objectsByTypeName { get; internal set; } = null!;
public static Dictionary<string, List<Fluid>> fluidVariants { get; internal set; } = null!;
public static Goods voidEnergy { get; internal set; } = null!;
public static Goods researchUnit { get; internal set; } = null!;
public static Goods science { get; internal set; } = null!;
public static Goods itemInput { get; internal set; } = null!;
public static Goods itemOutput { get; internal set; } = null!;
public static Goods electricity { get; internal set; } = null!;
Expand Down
1 change: 0 additions & 1 deletion Yafc.Parser/Data/DataParserUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public static class SpecialNames {
public const string RocketLaunch = "launch";
public const string RocketCraft = "rocket.";
public const string ReactorRecipe = "reactor";
public const string ResearchUnit = "research-unit";
public const string SpoilRecipe = "spoil";
public const string PlantRecipe = "plant";
public const string AsteroidCapture = "asteroid-capture";
Expand Down
16 changes: 8 additions & 8 deletions Yafc.Parser/Data/FactorioDataDeserializer_Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal partial class FactorioDataDeserializer {
private readonly Special heat;
private readonly Special electricity;
private readonly Special rocketLaunch;
private readonly Special researchUnit;
private readonly Item science;
private readonly Item totalItemOutput;
private readonly Item totalItemInput;
private readonly EntityEnergy voidEntityEnergy;
Expand Down Expand Up @@ -86,12 +86,12 @@ Item createSpecialItem(string name, string locName, string locDescr, string icon
rootAccessible.Add(voidEnergy);

rocketLaunch = createSpecialObject(false, SpecialNames.RocketLaunch, "Rocket launch slot",
"This is a slot in a rocket ready to be launched", "__base__/graphics/entity/rocket-silo/02-rocket.png", "signal-R");
researchUnit = createSpecialObject(false, SpecialNames.ResearchUnit, "Research",
"This represents one unit of a research task.", "__base__/graphics/icons/compilatron.png", "signal-L");
researchUnit.isResearch = true;
researchUnit.showInExplorers = false;
Analysis.ExcludeFromAnalysis<CostAnalysis>(researchUnit);
"This is a slot in a rocket ready to be launched", "__base__/graphics/entity/rocket-silo/rocket-static-pod.png", "signal-R");

science = GetObject<Item>("science");
science.showInExplorers = false;
Analysis.ExcludeFromAnalysis<CostAnalysis>(science);
formerAliases["Special.research-unit"] = science;

generatorProduction = CreateSpecialRecipe(electricity, SpecialNames.GeneratorRecipe, "generating");
generatorProduction.products = [new Product(electricity, 1f)];
Expand Down Expand Up @@ -189,7 +189,7 @@ private void ExportBuiltData() {

Database.allSciencePacks = [.. sciencePacks];
Database.voidEnergy = voidEnergy;
Database.researchUnit = researchUnit;
Database.science = science;
Database.itemInput = totalItemInput;
Database.itemOutput = totalItemOutput;
Database.electricity = electricity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private static void DeserializeFlags(LuaTable table, RecipeOrTechnology recipe)
private void DeserializeTechnology(LuaTable table, ErrorCollector errorCollector) {
var technology = DeserializeCommon<Technology>(table, "technology");
LoadTechnologyData(technology, table, errorCollector);
technology.products = [new(researchUnit, 1)];
technology.products = [new(science, 1)];
}

private void DeserializeQuality(LuaTable table, ErrorCollector errorCollector) {
Expand Down
2 changes: 1 addition & 1 deletion Yafc/Workspace/ProductionTable/ProductionTableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ void dropDownContent(ImGui gui) {
#region Recipe selection
int numberOfShownRecipes = 0;

if (goods.name == SpecialNames.ResearchUnit) {
if (goods == Database.science) {
if (gui.BuildButton("Add technology") && gui.CloseDropdown()) {
SelectMultiObjectPanel.Select(Database.technologies.all, "Select technology",
r => context.AddRecipe(r, DefaultVariantOrdering), checkMark: r => context.recipes.Any(rr => rr.recipe == r));
Expand Down

0 comments on commit b6cbe02

Please sign in to comment.