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 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-29 07:48:08 +01:00
commit b4e25c5821
2 changed files with 40 additions and 2 deletions

BIN
GameData/Aetheria.cc (Stored with Git LFS)

Binary file not shown.

View file

@ -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<SimpleCommodityData>().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<SimpleCommodityData>(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<AtmosphereData>(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);
}
}
}