diff --git a/Assets/Scripts/ServerShared/ZoneGenerator.cs b/Assets/Scripts/ServerShared/ZoneGenerator.cs index a10950bbf..e4316f68f 100644 --- a/Assets/Scripts/ServerShared/ZoneGenerator.cs +++ b/Assets/Scripts/ServerShared/ZoneGenerator.cs @@ -254,8 +254,7 @@ public static class ZoneGenerator { if (laneRandom.NextFloat() >= zoneSettings.LaneProbability) continue; var lane = zoneSettings.LaneBodyRadii * planetSettings.BodyRadius.Evaluate(host.Mass); - if (swarmHosts.Contains(host) || shaped.Contains(host.Parent) - || host.SlotInner > host.Distance - 2 * lane || host.SlotOuter < host.Distance + 2 * lane) continue; + if (swarmHosts.Contains(host) || shaped.Contains(host.Parent) || !LaneHost(host, lane)) continue; shaped.Add(host.Parent); var hostOrbit = orbitMap[host]; var rail = new OrbitData { Parent = hostOrbit.Parent, Distance = hostOrbit.Distance, Phase = hostOrbit.Phase }; @@ -672,6 +671,15 @@ public static class ZoneGenerator private const uint LaneStream = 0x85EBCA6Bu; + // Whether a placed body can carry a lane of half-width `lane`: its slot holds a band at least that wide on both sides + // (ruling lanes-two-sided-visual-margin), and it is not its parent's outermost child (ruling lane-not-outermost). Place + // stretches the chain to the window, so an outermost child's outer side is the window, not a sibling's spacing; a lane's outer + // band there would reach past every sibling's extent and raise its parent's support, and lanes move nothing else in the zone. + // An only child is its parent's outermost. + public static bool LaneHost(GeneratorPlanet host, float lane) => + host.Parent.Children.Any(c => c.Distance > host.Distance) + && host.SlotInner <= host.Distance - 2 * lane && host.SlotOuter >= host.Distance + 2 * lane; + // A laned belt's rocks: the count an annulus of the host's mass at `distance` would draw, over the bands [inner, distance - lane] // and [distance + lane, outer], each rock in a band by its area and drawn across it as the annulus draws across its width. public static Asteroid[] LaneRocks(ZoneGenerationSettings settings, ref Random random, float mass, float distance, float lane, float inner, float outer) diff --git a/tests/Aetheria.Shared.Tests/ChildrenWithinReachTests.cs b/tests/Aetheria.Shared.Tests/ChildrenWithinReachTests.cs index a5ab3ebc3..6a8bd72cb 100644 --- a/tests/Aetheria.Shared.Tests/ChildrenWithinReachTests.cs +++ b/tests/Aetheria.Shared.Tests/ChildrenWithinReachTests.cs @@ -446,14 +446,14 @@ public sealed class ChildrenWithinReachTests : IClassFixture= 10, $"only {filled} of {belts} belts fill the authored width"); } - private static GeneratorPlanet Body(GeneratorPlanet parent, float mass, float phase = 0, bool ring = false) + internal static GeneratorPlanet Body(GeneratorPlanet parent, float mass, float phase = 0, bool ring = false) { var node = new GeneratorPlanet { Parent = parent, Mass = mass, Phase = phase, Ring = ring }; parent.Children.Add(node); return node; } - private static PlanetSettings AuthoredPlanetSettings() => AuthoredSettings.Load(RunStartTests.FindRepoRoot()).Read("PlanetSettings"); + internal static PlanetSettings AuthoredPlanetSettings() => AuthoredSettings.Load(RunStartTests.FindRepoRoot()).Read("PlanetSettings"); // Two belts side by side under one parent (production never draws them; follow-up belt-after-belt-edge-pin): the second // belt's slot starts a sibling spacing outside the first belt's outer edge, not its rail, so their rock intervals keep a spacing. diff --git a/tests/Aetheria.Shared.Tests/LanedBeltTests.cs b/tests/Aetheria.Shared.Tests/LanedBeltTests.cs index 94d400d18..cb48aa5dc 100644 --- a/tests/Aetheria.Shared.Tests/LanedBeltTests.cs +++ b/tests/Aetheria.Shared.Tests/LanedBeltTests.cs @@ -4,10 +4,10 @@ using GameCult.Caching; using Xunit; using Xunit.Abstractions; -// Laned belts (rulings belt-shapes-direction, lanes-two-sided-visual-margin; map B60): a belt candidate that kept its body carries -// an annulus on a copy of its rail that fills the body's slot less a lane LaneBodyRadii body radii a side, with rocks on both -// sides; it is drawn from a stream of its own and sits inside the slot, so it moves nothing else in the zone. Seeds 1-6, authored -// settings, against the same seeds drawing no lane. +// Laned belts (rulings belt-shapes-direction, lanes-two-sided-visual-margin, lane-narrow, lane-not-outermost; map B60): a belt +// candidate that kept its body and is not its parent's outermost child carries an annulus on a copy of its rail that fills the +// body's slot less a lane LaneBodyRadii (1.5) body radii a side, with rocks on both sides; it is drawn from a stream of its own and +// sits inside the slot, so it moves nothing else in the zone. Seeds 1-6, authored settings, against the same seeds drawing no lane. public sealed class LanedBeltTests : IClassFixture { private const uint First = 1, Last = 6; @@ -140,6 +140,23 @@ public sealed class LanedBeltTests : IClassFixture Assert.True(lanes > 0, $"no lane in seeds {First}-{Last}"); } + // An only child is its parent's outermost (ruling lane-not-outermost): Place stretches nothing for it, so its slot runs out to + // the window and has room for a lane on both sides, yet its lane's outer band would sit past every sibling's extent and raise + // the parent's support. The host filter refuses it on that ground alone. + [Fact] + public void AnOnlyChildHostsNoLane() + { + var root = new GeneratorPlanet { Mass = 1e5f }; + var child = ChildrenWithinReachTests.Body(root, 10f); + var planetSettings = ChildrenWithinReachTests.AuthoredPlanetSettings(); + ZoneGenerator.Place(root, planetSettings, 1e6f, 1e5f); + var lane = _samples.Authored.Settings.LaneBodyRadii * planetSettings.BodyRadius.Evaluate(child.Mass); + _out.WriteLine($"only child at {child.Distance}, slot [{child.SlotInner}, {child.SlotOuter}], lane half-width {lane}"); + Assert.True(child.SlotInner <= child.Distance - 2 * lane && child.SlotOuter >= child.Distance + 2 * lane, + $"the only child's slot [{child.SlotInner}, {child.SlotOuter}] has no room for a lane of {lane} at {child.Distance}"); + Assert.False(ZoneGenerator.LaneHost(child, lane)); + } + // A belt's field kind is chosen at generation and saved with it (Mining Cut 3, Q16 B): every belt the generator writes, // annulus, swarm or lane, carries one before any Zone reads it (finding ensure-unpinned). [Fact]