diff --git a/GameData/Aetheria.cc b/GameData/Aetheria.cc index abb012cc4..3b66563cd 100644 --- a/GameData/Aetheria.cc +++ b/GameData/Aetheria.cc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:00e840dbad797c0ce62cb6038dea24963cbda2c273c1f5bcf22481bf2b10f4bf -size 293693 +oid sha256:0dae97097ea34d5423bc8876b84fc182223836437fc3103cd77999f5aaac5775 +size 293677 diff --git a/GameData/Mods/aetheria.seized-refinery/ship.cc b/GameData/Mods/aetheria.seized-refinery/ship.cc index 46c77cca7..fca0d9e67 100644 --- a/GameData/Mods/aetheria.seized-refinery/ship.cc +++ b/GameData/Mods/aetheria.seized-refinery/ship.cc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:78fbcc524b4a8537b8266b70700f41eb5f62019a7cb8a40bace90718eee1acd1 -size 11942 +oid sha256:daf286c0647f9e452279c9ab347ad5e2cedfdd267b226b55e3b4821fe2494b84 +size 11986 diff --git a/GameData/Mods/aetheria.seized-refinery/ship.glb b/GameData/Mods/aetheria.seized-refinery/ship.glb index 6fadc4319..2bde02ceb 100644 --- a/GameData/Mods/aetheria.seized-refinery/ship.glb +++ b/GameData/Mods/aetheria.seized-refinery/ship.glb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f86da950d672dbb40147668dcce187e6c438d7ad775be9bdb988601480b70c32 -size 192728 +oid sha256:2ac8f0fb74b33e85bccd2c5f8ba4c09a3ac49dcd4c8dbcad3f593410032a1179 +size 192832 diff --git a/tools/AetherDb/Economy/Facilities.cs b/tools/AetherDb/Economy/Facilities.cs index af1503738..3f52df8f6 100644 --- a/tools/AetherDb/Economy/Facilities.cs +++ b/tools/AetherDb/Economy/Facilities.cs @@ -8,8 +8,8 @@ using MessagePack; // Economy content: the facility gear a station is fitted with to run its recipes (aetheria-living-world, cut recipe-facilities; // rulings demand-consumed-inputs-processed-by-facilities, installed-gear-decides-what-a-station-buys). One facility design per station // kind that some recipe names, a 2x2 GearData on a Facility mount holding FacilityData, sold by a NotOffered product (a design no -// product sells is an unsold design; a not-offered product is on no market). Sets each kind's Facilities to its design and every -// recipe's Facility to its kind's. Writes whole values, only where they differ, so a rerun touches nothing. Price is a sim-tuned knob +// product sells is an unsold design; a not-offered product is on no market). Sets each kind's Facilities to its recipe design, then the +// silo when the silo lists the kind, and every recipe's Facility to its kind's. Writes whole values, only where they differ, so a rerun touches nothing. Price is a sim-tuned knob // (ruling economy-numbers-are-sim-tuned-knobs); names and descriptions are first drafts for the economy content pass. public sealed class Facilities : EconomyBatch { @@ -29,10 +29,11 @@ public sealed class Facilities : EconomyBatch ("munitions-works", "munitions-line", "Munitions Line", "A sealed line that makes energetics and loads rounds, primers, fuzes, warheads and motors."), }; - // The one storage facility: Zenith's ore silo (ruling demo-zenith-ore-depot). Storage, not a recipe facility, so it has no recipe and - // its kind is named here; a silo is bulk storage on a Facility row and holds only commodity stacks (SiloData). - private static readonly (string Kind, string Id, string Name, string Description) Silo = - ("trade-hub", "ore-silo", "Ore Silo", "A sealed bulk store that holds ore waiting for the haul to the refinery."); + // The one storage facility: the silo (rulings demo-zenith-ore-depot, facility-output-room). Storage, not a recipe facility, so it has no + // recipe and its kinds are named here: Zenith's trade hub holds the ore its orders haul, a processing station holds what its + // facilities make. A silo is bulk storage on a Facility row and holds only commodity stacks (SiloData). + private static readonly (string[] Kinds, string Id, string Name, string Description) Silo = + (new[] { "trade-hub", "processing" }, "ore-silo", "Silo", "A sealed bulk store for the goods a station hauls or makes."); // The kind's first facility design, or unset: the one lookup the recipe-writing batches use. public static CultRecordRef Of(CultCache catalog, string kindId) @@ -80,14 +81,18 @@ public sealed class Facilities : EconomyBatch Manufacturer = new CultRecordRef(maker.Key), NotOffered = true }, new CultRecordKey("product:facility:" + id)); - var kind = catalog.Get(new CultRecordKey(kindKey)) ?? throw new InvalidOperationException($"A recipe names station kind '{kindKey}', which the catalog does not hold."); - if (kind.Facilities.Count != 1 || !kind.Facilities[0].Key.Equals(designKey)) + } + AuthorSilo(author, catalog, (wanted, key) => Put(wanted, key)); + foreach (var kindKey in kinds.Concat(Silo.Kinds.Select(id => StationKindData.KeyOf(id).Value)).Distinct(StringComparer.Ordinal)) + { + var kind = catalog.Get(new CultRecordKey(kindKey)) ?? throw new InvalidOperationException($"Station kind '{kindKey}' is not in the catalog."); + var wanted = WantedFacilities(kindKey, kinds.Contains(kindKey)); + if (!kind.Facilities.Select(facility => facility.Key).SequenceEqual(wanted)) { - kind.Facilities = new List> { new CultRecordRef(designKey) }; + kind.Facilities = wanted.Select(key => new CultRecordRef(key)).ToList(); author.Put(kind, new CultRecordKey(kindKey)); } } - AuthorSilo(author, catalog, (wanted, key) => Put(wanted, key)); foreach (var recipe in catalog.GetAll().ToArray()) { var facility = FirstOf(catalog.Get(recipe.StationKind)); @@ -105,11 +110,20 @@ public sealed class Facilities : EconomyBatch return maker.Faction == null ? factions.First() : maker; } - // The silo design, its NotOffered product, and its kind's Facilities holding it: each only where it differs. Compared by fields, as - // the recipe facilities are. + // A kind's Facilities: its recipe facility when a recipe runs on it, then the silo when the silo lists the kind. + private static List WantedFacilities(string kindKey, bool runsRecipes) + { + var wanted = new List(); + var row = Table.SingleOrDefault(entry => StationKindData.KeyOf(entry.Kind).Value == kindKey); + if (runsRecipes && row.Id != null) wanted.Add(new CultRecordKey("facility:" + row.Id)); + if (Silo.Kinds.Any(id => StationKindData.KeyOf(id).Value == kindKey)) wanted.Add(new CultRecordKey("facility:" + Silo.Id)); + return wanted; + } + + // The silo design and its NotOffered product: each only where it differs. Compared by fields, as the recipe facilities are. private static void AuthorSilo(EconomyAuthor author, CultCache catalog, Action put) { - var (kindId, id, name, description) = Silo; + var (kindIds, id, name, description) = Silo; var designKey = new CultRecordKey("facility:" + id); var shape = new Shape(2, 2); foreach (var cell in shape.AllCoordinates) shape[cell] = true; @@ -125,18 +139,11 @@ public sealed class Facilities : EconomyBatch Durability = 100, Mass = 250, Price = 1000, MinimumTemperature = ThermalMin, MaximumTemperature = ThermalMax, OptimalTemperature = ThermalOptimal, PlateauWidth = ThermalPlateau }, designKey); - var kindKey = StationKindData.KeyOf(kindId); - var maker = MakerOf(catalog, kindKey.Value); + var maker = MakerOf(catalog, StationKindData.KeyOf(kindIds[0]).Value); put(new FactionProductData { Name = $"{maker.Faction.Name} {name}", Description = description, Design = new CultRecordRef(designKey), Manufacturer = new CultRecordRef(maker.Key), NotOffered = true }, new CultRecordKey("product:facility:" + id)); - var kind = catalog.Get(kindKey) ?? throw new InvalidOperationException($"The silo's station kind '{kindId}' is not in the catalog."); - if (kind.Facilities.Count != 1 || !kind.Facilities[0].Key.Equals(designKey)) - { - kind.Facilities = new List> { new CultRecordRef(designKey) }; - author.Put(kind, kindKey); - } } } diff --git a/tools/blender/manifests/seized-refinery/package.json b/tools/blender/manifests/seized-refinery/package.json index ea068d811..9e252e0c6 100644 --- a/tools/blender/manifests/seized-refinery/package.json +++ b/tools/blender/manifests/seized-refinery/package.json @@ -15,6 +15,7 @@ {"id": "Reactor", "kind": "Reactor", "cell": [3, 0], "footprint": "####/####/####/####", "rotation": 0, "armor": 0, "arc": 0}, {"id": "Ra.1", "kind": "Radiator", "cell": [0, 3], "footprint": "#/#/#/#", "rotation": 1, "armor": 0, "arc": 0}, {"id": "Ra.2", "kind": "Radiator", "cell": [11, 4], "footprint": "#/#/#/#", "rotation": 3, "armor": 0, "arc": 0}, - {"id": "Fa.1", "kind": "Facility", "cell": [4, 10], "footprint": "##/##", "rotation": 0, "armor": 0, "arc": 0} + {"id": "Fa.1", "kind": "Facility", "cell": [4, 10], "footprint": "##/##", "rotation": 0, "armor": 0, "arc": 0}, + {"id": "Fa.2", "kind": "Facility", "cell": [6, 9], "footprint": "##/##", "rotation": 0, "armor": 0, "arc": 0} ] }