From b4e25c58212ba88f196f531c3a7af005308ae5e0 Mon Sep 17 00:00:00 2001 From: soul Date: Sun, 29 Nov 2026 07:48:08 +0100 Subject: [PATCH] Atmospheres batch and Aetheria.cc: atmosphere:gas-giant, the ground a skimmer skims economy author Atmospheres apply wrote one record, Methane 3, Water 2, Ammonia 1 (first-draft knobs, ruling economy-numbers-are-sim-tuned-knobs); the reprice that follows touched nothing. The batch writes only where the record differs by fields. Co-Authored-By: Claude Sonnet 5.5 --- GameData/Aetheria.cc | 4 +-- tools/AetherDb/Economy/Atmospheres.cs | 38 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tools/AetherDb/Economy/Atmospheres.cs diff --git a/GameData/Aetheria.cc b/GameData/Aetheria.cc index fc921bb43..8c2e349c3 100644 --- a/GameData/Aetheria.cc +++ b/GameData/Aetheria.cc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9d0454a817cca1b4cab20694b01b310e27879f997942affc533d3e078225c7d5 -size 294811 +oid sha256:e87c771e9e21d5d6103f136d812a4e2b368d49377b0f793c66dac1267b22a1c3 +size 295835 diff --git a/tools/AetherDb/Economy/Atmospheres.cs b/tools/AetherDb/Economy/Atmospheres.cs new file mode 100644 index 000000000..ef1a20683 --- /dev/null +++ b/tools/AetherDb/Economy/Atmospheres.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using GameCult.Caching; + +// Economy content: what a gas giant's atmosphere holds (aetheria-living-world, cut facility-extraction; ruling economy-is-never-faked, +// auto-mining-is-off-screen-only). One record, atmosphere:gas-giant, read by Deposits for every gas giant that is not a sun and by +// the Volatiles Skimmer's raw recipes through it. Volatiles are not ore (FieldKinds.IsOre reads field kinds only). The abundances are +// sim-tuned knobs (ruling economy-numbers-are-sim-tuned-knobs): first draft Methane 3, Water 2, Ammonia 1. Writes only where the stored +// record differs by fields, so a rerun touches nothing. +public sealed class Atmospheres : EconomyBatch +{ + private static readonly (string Id, string Name, (string Good, float Abundance)[] Yields)[] Table = + { + (Deposits.GasGiantAtmosphere, "Gas Giant Atmosphere", new[] { ("Ammonia", 1f), ("Methane", 3f), ("Water", 2f) }) + }; + + public override void Author(EconomyAuthor author) + { + var catalog = author.Catalog; + foreach (var (id, name, yields) in Table) + { + var wanted = new AtmosphereData { Name = name }; + foreach (var (good, abundance) in yields) + { + var named = catalog.GetAll().Where(commodity => commodity.Name == good).ToArray(); + if (named.Length != 1) throw new InvalidOperationException($"The catalog holds {named.Length} commodities named '{good}', and an atmosphere needs exactly one."); + wanted.Yields.Add(new FieldYield { Commodity = new CultRecordRef(catalog.RefOf(named[0]).Key), Abundance = abundance }); + } + // A stored yield carries a cache-minted element id, so a record is compared by its fields, never by bytes. + var key = AtmosphereData.KeyOf(id); + var held = catalog.Get(key); + var same = held != null && held.Name == wanted.Name && held.Yields.Count == wanted.Yields.Count + && held.Yields.Zip(wanted.Yields, (a, b) => a.Commodity.Key.Equals(b.Commodity.Key) && a.Abundance == b.Abundance && a.Regional == b.Regional).All(equal => equal); + if (!same) author.Put(wanted, key); + } + } +}