Gravity subtract: delete the zone bowl and the gas-giant and sun ripples

GetHeight sums body wells only. Removes RadialWaves, GasGiant wave fields,
GasGiantData keys 14-17, PlanetSettings Zone*/Wave* fields, the minimap
gravity range, the Boundary brush and Gravity Waves objects from the scene
and both prefabs. The five bowl fixtures become one WellFixture well at the
origin with unchanged expected numbers. Not yet built or tested: this commit
has not been through the Yggdrasil job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-14 19:34:20 +02:00
commit 7d3fb29ed2
18 changed files with 180 additions and 354 deletions

View file

@ -41,7 +41,11 @@ public sealed class FireControlTests : IDisposable
// A hull with one weapon hardpoint per (rotation, firingArc) pair, laid out along the X axis of a 1xN
// shape so each gets its own cell. FiringArc 0 on a hardpoint means "use GameplaySettings.FiringArc".
private (ItemManager items, Ship ship, EquippedItem[] weapons) BuildShipWithHardpoints(
params (ItemRotation rotation, float firingArc)[] hardpoints)
params (ItemRotation rotation, float firingArc)[] hardpoints) => BuildShipWithHardpoints(false, hardpoints);
// `well` digs the zone one well at the origin (WellFixture), so heights differ across the zone.
private (ItemManager items, Ship ship, EquippedItem[] weapons) BuildShipWithHardpoints(
bool well, (ItemRotation rotation, float firingArc)[] hardpoints)
{
var hullShape = new Shape(Math.Max(hardpoints.Length, 3), 3);
foreach (var cell in hullShape.AllCoordinates) hullShape[cell] = true;
@ -84,7 +88,10 @@ public sealed class FireControlTests : IDisposable
for (var i = 0; i < hardpoints.Length; i++)
ledger.Lots[2 + i] = new Lot { Origin = new Attributed(), Quality = 1 }; // guns
var items = new ItemManager(_openCache, ledger, TestSettings(), _ => { });
var zone = new Zone(items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = "Test Zone", Owner = null }, null);
var planets = new PlanetSettings();
var pack = new ZonePack();
if (well) WellFixture.Dig(_openCache, pack, planets, pack.Radius, 1000f, 1f);
var zone = new Zone(items, planets, pack, new GalaxyZone { Name = "Test Zone", Owner = null }, null);
var hullRef = items.ItemData.RefOf<ItemData>(items.ItemData.GetByName<HullData>("TestHull"));
var hull = new EquippableItem { Data = hullRef, Durability = 1, Lot = 1 };
@ -182,10 +189,10 @@ public sealed class FireControlTests : IDisposable
}
// A shooter with one in-range, in-arc gun, a detected target at `targetPosition`, and a Minion driving the shooter.
private (Ship shooter, Ship target, Zone zone) BuildCombatEncounter(float3 targetPosition, float projectileSpeed = 0f, bool twoTargetGuns = false)
private (Ship shooter, Ship target, Zone zone) BuildCombatEncounter(float3 targetPosition, float projectileSpeed = 0f, bool twoTargetGuns = false, bool well = false)
{
var mounts = twoTargetGuns ? new[] { (ItemRotation.None, 0f), (ItemRotation.None, 0f) } : new[] { (ItemRotation.None, 0f) };
var (items, shooter, weapons) = BuildShipWithHardpoints(mounts);
var (items, shooter, weapons) = BuildShipWithHardpoints(well, mounts);
var weaponData = (InstantWeaponData) weapons[0].Data.Behaviors.Single(b => b is InstantWeaponData);
weaponData.Damage = new PerformanceStat { Min = 10, Max = 10 };
weaponData.Cooldown = new PerformanceStat { Min = 1, Max = 1 };
@ -376,9 +383,7 @@ public sealed class FireControlTests : IDisposable
[Fact]
public void TheAIMeasuresTheTargetOnTheGroundPlane()
{
var (shooter, target, zone) = BuildCombatEncounter(float3(0, 0, 600), twoTargetGuns: true);
zone.Settings.ZoneDepth = 1000f;
zone.Settings.ZoneDepthExponent = 1f;
var (shooter, target, zone) = BuildCombatEncounter(float3(0, 0, 600), twoTargetGuns: true, well: true);
var strong = target.Equipment.Single(x => x.Data.Name == "Gun");
var weak = target.Equipment.Single(x => x.Data.Name == "WeakGun");
zone.Update(1f); // heights follow the zone's depth from the first update

View file

@ -230,8 +230,10 @@ public sealed class FloatingBodyTests : IDisposable
QualityPriceModifier = new ExponentialLerp()
};
var items = new ItemManager(cache, new ProvenanceLedger(), settings, _ => { });
var planets = new PlanetSettings { ZoneDepth = 1000, ZoneDepthExponent = 1, GravityStrength = 1 };
zone = new Zone(items, planets, new ZonePack { Radius = 1000 }, new GalaxyZone { Name = "Test Zone", Owner = null }, null);
var planets = new PlanetSettings { GravityStrength = 1 };
var pack = new ZonePack { Radius = 1000 };
WellFixture.Dig(cache, pack, planets, 1000, 1000, 1);
zone = new Zone(items, planets, pack, new GalaxyZone { Name = "Test Zone", Owner = null }, null);
var design = cache.GetByName<HullData>("Skiff");
var hull = new EquippableItem
{

View file

@ -46,9 +46,13 @@ public sealed class FlowFieldTests : IDisposable
};
// A zone at `time` (the pack's clock, as a saved zone restores it), flat unless `depth` digs the zone's own well.
private Zone ZoneWith(FlowSettings flow, double time = 0, float depth = 0f) => new Zone(_items,
new PlanetSettings { Flow = flow, ZoneDepth = depth, ZoneDepthExponent = 2f },
new ZonePack { Time = time }, new GalaxyZone { Name = "Flow Zone", Owner = null }, null);
private Zone ZoneWith(FlowSettings flow, double time = 0, float depth = 0f)
{
var planets = new PlanetSettings { Flow = flow };
var pack = new ZonePack { Time = time };
if (depth > 0f) WellFixture.Dig(_items.ItemData, pack, planets, pack.Radius, depth, 2f);
return new Zone(_items, planets, pack, new GalaxyZone { Name = "Flow Zone", Owner = null }, null);
}
private static readonly float3[] Probes =
{

View file

@ -0,0 +1,117 @@
using System;
using System.IO;
using CultMath;
using GameCult.Caching;
using Xunit;
using float2 = CultMath.float2;
using float3 = CultMath.float3;
// flatspace-no-bowl-no-ripples (aetheria-gravity target r3): a zone's height is the sum of its bodies' wells and
// nothing else. No zone-wide bowl sized by the pack, and no gas-giant or sun ripple that varies with zone time.
public sealed class GravitySubtractTests : IDisposable
{
private readonly string _root = Path.Combine(Path.GetTempPath(), "aetheria-gravsub-" + Guid.NewGuid().ToString("N"));
private readonly CultCache _cache;
private readonly ItemManager _items;
public GravitySubtractTests()
{
Directory.CreateDirectory(_root);
_cache = AetheriaStores.Open(Path.Combine(_root, "grav.cc"), catalogWritable: true);
_cache.Upsert(new VerseGrammar { Revision = 1 });
_cache.FlushAsync().Wait();
var settings = new GameplaySettings
{
DefaultEntitySettings = new EntitySettings(),
Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } },
QualityPriceModifier = new ExponentialLerp(),
TargetDetectionInfoThreshold = .1f, TargetGearInfoThreshold = .8f,
FiringArc = 170, CommitHorizon = .5f, SchematicCellSize = 2f
};
_items = new ItemManager(_cache, new ProvenanceLedger(), settings, _ => { });
}
public void Dispose()
{
_cache.Dispose();
Directory.Delete(_root, true);
}
// Curves for a body whose well, light and orbit all vary with mass, so a body that read a different
// mass or multiplier than its twin would show it.
private static PlanetSettings Planets() => new PlanetSettings
{
GravityStrength = 1,
BodyRadius = new ExponentialCurve { Exponent = .25f, Multiplier = 3f },
GravityRadius = new ExponentialCurve { Exponent = .25f, Multiplier = 500f },
GravityDepth = new ExponentialCurve { Exponent = .175f, Multiplier = 30f },
LightRadius = new ExponentialCurve { Exponent = .25f, Multiplier = 300f },
OrbitPeriod = new ExponentialCurve()
};
private Zone Bare(float packRadius) => new Zone(_items, Planets(), new ZonePack { Radius = packRadius },
new GalaxyZone { Name = "Bare Zone", Owner = null }, null);
[Fact]
public void AZoneWithNoBodiesIsFlat()
{
foreach (var packRadius in new[] { 1000f, 2500f })
{
var zone = Bare(packRadius);
foreach (var r in new[] { 0f, 300f, 577f, 900f, 2000f })
{
var at = new float2(r, 0);
Assert.Equal(0f, zone.GetHeight(at));
Assert.Equal(0f, zone.GetForce(at).x);
Assert.Equal(0f, zone.GetForce(at).y);
var inPlane = new float2(0, r);
Assert.Equal(0f, zone.GetHeight(inPlane));
Assert.Equal(0f, zone.GetForce(inPlane).x);
Assert.Equal(0f, zone.GetForce(inPlane).y);
}
}
}
// One body of `data` at the origin of a zone whose only body it is.
private Zone WithBody(BodyData data)
{
var orbit = _cache.Upsert(new OrbitData { FixedPosition = float2.zero }).Key;
data.Orbit = new CultRecordRef<OrbitData>(orbit);
data.Mass = 100f;
data.GravityRadiusMultiplier = 1.5f;
data.GravityDepthMultiplier = .7f;
data.GravityDepthExponent = 2f;
var body = _cache.Upsert(data).Key;
var pack = new ZonePack { Radius = 1000f };
pack.Orbits.Add(new CultRecordRef<OrbitData>(orbit));
pack.Planets.Add(new CultRecordRef<BodyData>(body));
return new Zone(_items, Planets(), pack, new GalaxyZone { Name = "Giant " + data.GetType().Name, Owner = null }, null);
}
[Fact]
public void AGiantsWellIsAPlainWellAtEveryTime()
{
var plain = WithBody(new PlanetData());
var giants = new[] { WithBody(new GasGiantData()), WithBody(new SunData()) };
foreach (var time in new[] { 0f, 37.5f })
{
// Zone time 0 is the zones as built; 37.5 is one Update of that length.
if (time > 0f)
{
plain.Update(time);
foreach (var giant in giants) giant.Update(time);
}
foreach (var r in new[] { 50f, 200f, 400f })
{
var at = new float2(r, 0);
Assert.True(plain.GetHeight(at) < 0f, "the plain body digs a well here, so there is something to compare");
foreach (var giant in giants)
{
Assert.Equal(plain.GetHeight(at), giant.GetHeight(at));
Assert.Equal(plain.GetForce(at).x, giant.GetForce(at).x);
Assert.Equal(plain.GetForce(at).y, giant.GetForce(at).y);
}
}
}
}
}

View file

@ -61,7 +61,7 @@ public sealed class LootTests : IDisposable
}
private Lab Build(string zoneName = "Loot", float probability = .5f, float lifetime = 30f, float velocity = 25f,
PlanetSettings planets = null, float spread = 0f)
bool well = false, float spread = 0f)
{
var settings = new GameplaySettings
{
@ -108,7 +108,14 @@ public sealed class LootTests : IDisposable
var ledger = new ProvenanceLedger();
for (var i = 1; i <= 9000; i++) ledger.Lots[i] = new Lot { Origin = new Attributed(), Quality = 1 };
var items = new ItemManager(cache, ledger, settings, _ => { });
var zone = new Zone(items, planets ?? new PlanetSettings(), new ZonePack { Radius = planets == null ? 0 : 1000 }, new GalaxyZone { Name = zoneName, Owner = null }, null);
var planets = new PlanetSettings();
var pack = new ZonePack { Radius = well ? 1000 : 0 };
if (well)
{
planets.GravityStrength = 1;
WellFixture.Dig(cache, pack, planets, 1000, 1000, 1);
}
var zone = new Zone(items, planets, pack, new GalaxyZone { Name = zoneName, Owner = null }, null);
return new Lab { Items = items, Zone = zone };
}
@ -286,8 +293,7 @@ public sealed class LootTests : IDisposable
[Fact]
public void AFloatingItemDriftsAsABodyAndExpires()
{
var planets = new PlanetSettings { ZoneDepth = 1000, ZoneDepthExponent = 1, GravityStrength = 1 };
var lab = Build(lifetime: 3f, planets: planets);
var lab = Build(lifetime: 3f, well: true);
var settings = lab.Items.GameplaySettings;
var start = new float2(40, -25);
var launch = new float2(6, 2);

View file

@ -118,8 +118,10 @@ public sealed class MineTests : IDisposable
var ledger = new ProvenanceLedger();
for (var i = 1; i <= 500; i++) ledger.Lots[i] = new Lot { Origin = new Attributed(), Quality = 1 };
var items = new ItemManager(cache, ledger, settings, _ => { });
var planets = well ? new PlanetSettings { ZoneDepth = 1000, ZoneDepthExponent = 1, GravityStrength = 1 } : new PlanetSettings();
var zone = new Zone(items, planets, new ZonePack { Radius = well ? 1000 : 0 }, new GalaxyZone { Name = "Mines", Owner = null }, null);
var planets = well ? new PlanetSettings { GravityStrength = 1 } : new PlanetSettings();
var pack = new ZonePack { Radius = well ? 1000 : 0 };
if (well) WellFixture.Dig(cache, pack, planets, 1000, 1000, 1);
var zone = new Zone(items, planets, pack, new GalaxyZone { Name = "Mines", Owner = null }, null);
var lab = new Lab { Items = items, Zone = zone, Data = data, ItemData = cache.GetByName<WeaponItemData>("Mine Layer") };
var layerRef = items.ItemData.RefOf<ItemData>(items.ItemData.GetByName<HullData>("Layer"));

View file

@ -58,10 +58,6 @@ public sealed partial class MiningCut3Tests : IDisposable
BodyRadius = new ExponentialCurve(),
GravityRadius = new ExponentialCurve(),
GravityDepth = new ExponentialCurve(),
WaveDepth = new ExponentialCurve(),
WaveRadius = new ExponentialCurve(),
WaveSpeed = new ExponentialCurve(),
WaveFrequency = new ExponentialCurve(),
LightRadius = new ExponentialCurve { Constant = lightRadius }
};

View file

@ -0,0 +1,21 @@
using CultMath;
using GameCult.Caching;
// The one fixture that gives a test zone a slope: a single body on a parentless orbit at the origin, with
// the curves a body needs. Gravity height is the sum of body wells, so a test that wants ground to slide on
// digs it here and nowhere else. `radius` is the zone radius the well is sized to (its well reaches 2 x radius,
// as the former bowl did); the well is deepest at the centre and zero at and beyond half its radius.
internal static class WellFixture
{
public static void Dig(CultCache cache, ZonePack pack, PlanetSettings settings, float radius, float depth, float exponent)
{
settings.BodyRadius = new ExponentialCurve();
settings.OrbitPeriod = new ExponentialCurve();
settings.GravityRadius = new ExponentialCurve { Constant = 2f * radius };
settings.GravityDepth = new ExponentialCurve { Constant = depth };
var orbit = cache.Upsert(new OrbitData { FixedPosition = float2.zero }).Key;
var body = cache.Upsert(new PlanetData { Orbit = new CultRecordRef<OrbitData>(orbit), GravityDepthExponent = exponent }).Key;
pack.Orbits.Add(new CultRecordRef<OrbitData>(orbit));
pack.Planets.Add(new CultRecordRef<BodyData>(body));
}
}