diff --git a/GameData/Aetheria.cc b/GameData/Aetheria.cc index 675434aba..1d130d001 100644 --- a/GameData/Aetheria.cc +++ b/GameData/Aetheria.cc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:56b4875145c5dc2552a94318a593d11bbcf35db4fabdd7cbfda71552bcedd834 -size 12698071 +oid sha256:5e3b717b0c4dc5b2b9903ba472710719d27bb9c8d518559e607726e14916499f +size 12698849 diff --git a/tests/Aetheria.Shared.Tests/RunStartTests.cs b/tests/Aetheria.Shared.Tests/RunStartTests.cs index fd0356ef9..152efd675 100644 --- a/tests/Aetheria.Shared.Tests/RunStartTests.cs +++ b/tests/Aetheria.Shared.Tests/RunStartTests.cs @@ -404,9 +404,9 @@ public sealed class RunStartTests : IDisposable private static bool IsHeater(EquippedItem item) => item.Behaviors.OfType().Any(t => !t.ThermotoggleData.HighPass) && item.Behaviors.OfType().Any(); - // Every generated station carries exactly one heater. + // Every generated station carries exactly one heater, and a reactor to power it. [Fact] - public void EveryGeneratedStationCarriesOneHeater() + public void EveryGeneratedStationCarriesOneHeaterAndAReactor() { var zone = Arena(null); var generator = new LoadoutGenerator(ref _items.Random, _items, _galaxy, _galaxy.Entrance, _protagonist, .5f); @@ -414,9 +414,54 @@ public sealed class RunStartTests : IDisposable { var station = EntitySerializer.Unpack(_items, zone, generator.GenerateStationLoadout()); Assert.True(station.Equipment.Count(IsHeater) == 1, $"station {i} carries {station.Equipment.Count(IsHeater)} heaters"); + Assert.True(station.Equipment.Any(item => item.Behaviors.OfType().Any()), $"station {i} has no reactor"); } } + private const float Freezing = 273.15f; + + // An idle station, powered by its reactor, holds its heater's cells (where the thermostat reads) above freezing + // over the second five of ten idle minutes. Unpowered, they cool from 280 K to about 247 K in that time. (The + // station's border cells still sit near 265 K; how warm the whole hull should run is a tuning question.) + [Fact] + public void AnIdleStationStaysAboveFreezing() + { + var zone = Arena(new Scenario { Ambient = false }); // no ships: nothing but the zone runs + var station = zone.Entities.First(entity => entity is OrbitalEntity && entity.DockingBays.Count > 0); + var heater = station.Equipment.Single(IsHeater); + var coldest = float.MaxValue; + for (var tick = 0; tick < 6000; tick++) + { + zone.Update(.1f); + if (tick >= 3000) coldest = min(coldest, heater.Temperature); + } + Assert.True(coldest > Freezing, $"the heater's cells fell to {coldest} K (station now {station.MinTemp}..{station.MaxTemp} K)"); + } + + // A station hull with no room left for a heater fails its generation by name, rather than spawning a station + // that will freeze. The only station hull on offer is one whose interior takes the smallest docking bay and no more. + [Fact] + public void AStationWithNoRoomForAHeaterFailsLoudly() + { + var sold = _cache.GetAll().Select(product => product.Design.Key).ToHashSet(); + var bay = _cache.GetAll().Where(design => sold.Contains(_cache.RefOf(design).Key)) + .OrderBy(design => design.Shape.Coordinates.Length).ThenBy(design => design.Name, StringComparer.Ordinal).First(); + var shape = new Shape(bay.Shape.Width + 2, bay.Shape.Height + 2); + foreach (var cell in shape.AllCoordinates) shape[cell] = true; + var cramped = new HullData { Name = "Cramped Station", HullType = HullType.Station, Shape = shape, Durability = 100, Mass = 1000, Price = 1 }; + _cache.Upsert(cramped); + _cache.Upsert(new FactionProductData + { + Name = "Cramped Station", Design = new CultRecordRef(_cache.RefOf(cramped).Key), Manufacturer = _cache.RefOf(_protagonist) + }); + foreach (var hull in _cache.GetAll().Where(hull => hull.HullType == HullType.Station && hull != cramped)) + hull.Price = 0; // generation offers no zero-price design, so the cramped hull is the only station + var generator = new LoadoutGenerator(ref _items.Random, _items, _galaxy, _galaxy.Entrance, _protagonist, .5f); + + var failure = Assert.Throws(() => generator.GenerateStationLoadout()); + Assert.Contains("heater", failure.Message); + } + // Q3, with the operator's 2026-09-30 ruling on the ten product-less designs: a design no product sells is a // scenario test design and nothing else. A test design is one a scenario places: its preset's hull or a slot of // it, or cargo it carries. These are the unsold designs no scenario places, by name. diff --git a/tools/AetherDb/Program.cs b/tools/AetherDb/Program.cs index 4635800a6..88762abc5 100644 --- a/tools/AetherDb/Program.cs +++ b/tools/AetherDb/Program.cs @@ -37,8 +37,9 @@ public static class Program case "targeting-catalog-6c": return TargetingCatalog6c(args.Contains("apply")); case "targeting-catalog-6d": return TargetingCatalog6d(args.Contains("apply")); case "product-gap": return ProductGap(args.Contains("apply")); + case "station-reactor": return StationReactor(args.Contains("apply")); default: - Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear ]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], product-gap [apply]"); + Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, loadout [seed], save, settings, settings-dump, dangling [clear ]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], product-gap [apply], station-reactor [apply]"); return 1; } } @@ -1555,4 +1556,71 @@ public static class Program Console.WriteLine($"\nLanded {industrial.Length} deletions, {made.Length} products and the heater's price and durability in Aetheria.cc"); return 0; } + + // Scenarios map, operator ruling 2026-09-30 ("Yep, we need a station reactor"): Zenith's 16-cell Reactor hardpoint + // had no design to fill it, so generated stations had no power and their heater never ran. The station reactor is + // Manhattan, the largest and most industrial reactor, scaled to the slot: a full 4x4, its charge, mass and price + // times 16/9 (its cells over Manhattan's), every other value and stat term Manhattan's own, sold by Manhattan's maker. + private static int StationReactor(bool apply) + { + var db = AetherDb.Open(catalogWritable: apply); + var cache = db.Cache; + if (cache.GetAll().Any(d => d.Name == "Station Reactor")) throw new InvalidOperationException("Station Reactor already exists."); + var manhattan = cache.GetAll().Single(d => d.Name == "Manhattan"); + var manhattanProduct = cache.GetAll().Single(p => p.Design.Key.Equals(cache.RefOf(manhattan).Key)); + const float scale = 16f / 9f; + + var shape = new Shape(4, 4); + foreach (var cell in shape.AllCoordinates) shape[cell] = true; + var design = new GearData + { + Name = "Station Reactor", + Description = "A reactor sized for a station's core.", + Hardpoint = HardpointType.Reactor, + Shape = shape, + Mass = manhattan.Mass * scale, + Price = (int) Math.Round(manhattan.Price * scale / 50000) * 50000, + SpecificHeat = manhattan.SpecificHeat, + Conductivity = manhattan.Conductivity, + Durability = manhattan.Durability, + MinimumTemperature = manhattan.MinimumTemperature, + MaximumTemperature = manhattan.MaximumTemperature, + OptimalTemperature = manhattan.OptimalTemperature, + PlateauWidth = manhattan.PlateauWidth, + ThermalResilience = manhattan.ThermalResilience, + SoundBank = manhattan.SoundBank, + Roles = manhattan.Roles.Select(role => new ItemRole { Name = role.Name }).ToList(), + Behaviors = MessagePack.MessagePackSerializer.Deserialize>(MessagePack.MessagePackSerializer.Serialize(manhattan.Behaviors)), + }; + var reactor = design.Behaviors.OfType().Single(); + reactor.Charge.Min *= scale; + reactor.Charge.Max *= scale; + var product = new FactionProductData + { + Name = "Station Reactor", + Description = "", + Manufacturer = manhattanProduct.Manufacturer, + Roles = design.Roles.Select(role => new ProductRole { Role = role.Name }).ToList(), + }; + + Console.WriteLine($"Station Reactor, from Manhattan x {scale:F3}: shape 4x4 (16), mass {manhattan.Mass} -> {design.Mass}, " + + $"price {manhattan.Price} -> {design.Price}, charge {reactor.Charge.Min / scale}..{reactor.Charge.Max / scale} -> {reactor.Charge.Min}..{reactor.Charge.Max}; " + + $"product by {cache.Get(product.Manufacturer).Name}"); + if (!apply) + { + Console.WriteLine("\nDry run. Pass \"apply\" to land it."); + return 0; + } + + CultRecordRefs.Validate(design); + var key = new CultRecordKey(Guid.NewGuid().ToString("N")); + product.Design = new CultRecordRef(key); + cache.Commit(batch => + { + batch.Upsert(typeof(GearData), design, key); + batch.Upsert(typeof(FactionProductData), product, new CultRecordKey(Guid.NewGuid().ToString("N"))); + }); + Console.WriteLine("\nLanded the Station Reactor and its product in Aetheria.cc"); + return 0; + } }