From 8128bce6ba0229d7fd75365466b2ee22e2124987 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 12 Oct 2026 03:38:06 +0200 Subject: [PATCH] Belt scenario: an arena on seed 24, whose entrance zone carries a 615-rock belt, the player parked 100 m outside its ring Spec cut-scenarios-belt.r1. Scenarios/Belt.cs stages the Longinus at the ring's edge nearest the origin facing along it; BeltConditions in BeltScenarioTests.cs pins it. Built and tested through ygg-verify in the next commit's verification. --- Assets/Scripts/ServerShared/Scenarios/Belt.cs | 48 +++++++++++++++++++ .../ServerShared/Scenarios/Belt.cs.meta | 11 +++++ .../ServerShared/Scenarios/Scenarios.cs | 2 +- .../BeltScenarioTests.cs | 42 ++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 Assets/Scripts/ServerShared/Scenarios/Belt.cs create mode 100644 Assets/Scripts/ServerShared/Scenarios/Belt.cs.meta create mode 100644 tests/Aetheria.Shared.Tests/BeltScenarioTests.cs diff --git a/Assets/Scripts/ServerShared/Scenarios/Belt.cs b/Assets/Scripts/ServerShared/Scenarios/Belt.cs new file mode 100644 index 000000000..61f2d278b --- /dev/null +++ b/Assets/Scripts/ServerShared/Scenarios/Belt.cs @@ -0,0 +1,48 @@ +using System.Linq; +using static CultMath.math; +using static ItemRotation; + +public sealed class Belt : Scenario +{ + public override string Name => "Belt"; + public override string Brief => "The biggest asteroid belt the generator made, with the Longinus parked 100 m outside its ring, facing along it, " + + "and nothing else in the arena. Verify: next and previous target step through the rocks and the reticle sweeps " + + "across the belt without a hitch; Previous with nothing targeted takes the farthest rock; the target indicator " + + "sits on the rock it names."; + + // Seeds 1-256 scanned for the arena whose entrance zone holds the belt with the most asteroids: seed 24, a belt of + // 615 rocks. The next four: 179 (553), 251 (548), 221 (532), 29 (515). + public override uint Seed => 24; + public override bool Ambient => false; + + public override Galaxy Generate(GalaxyStage stage) => stage.Prelude(DemoTerminus.Cast); + + public override void Stage(ScenarioStage stage) + { + var fighter = stage.Fit("Longinus", + ("Cockpit 2x2", int2(2, 6), None), + ("Large Drive", int2(1, 0), Reversed), + ("Large Drive", int2(3, 0), Reversed), + ("Talaria", int2(2, 14), CounterClockwise), + ("Talaria", int2(3, 14), Clockwise), + ("Core Power", int2(2, 4), None), + ("GT 3K", int2(0, 5), None), + ("GT 3K", int2(5, 5), None), + ("plight", int2(1, 8), None), + ("FastBlast+-", int2(4, 8), None), + ("Iapyx", int2(2, 2), CounterClockwise), + ("Iapyx", int2(3, 2), Clockwise), + ("not if i see you first", int2(3, 10), None), + ("Fire Control Array", int2(1, 6), Clockwise)); + + // The belt is a ring about its parent's position at the belt orbit's distance. The player stands 100 m outside + // it, at the point nearest the origin, facing along the ring. + var arena = stage.Arena; + var belt = arena.Planets.Values.OfType().OrderByDescending(candidate => candidate.Asteroids.Length).First(); + var orbit = arena.Orbits[belt.Orbit.Key].Data; + var centre = arena.GetOrbitPosition(orbit.Parent.Key); + var outward = lengthsq(centre) > 0f ? normalize(-centre) : float2(1, 0); + var at = centre + outward * (orbit.Distance + 100f); + stage.Player(fighter, at, facing: float2(-outward.y, outward.x)); + } +} diff --git a/Assets/Scripts/ServerShared/Scenarios/Belt.cs.meta b/Assets/Scripts/ServerShared/Scenarios/Belt.cs.meta new file mode 100644 index 000000000..375ec1cb9 --- /dev/null +++ b/Assets/Scripts/ServerShared/Scenarios/Belt.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6177c598b87544d6bb0cefdfb4f01acc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/Scenarios/Scenarios.cs b/Assets/Scripts/ServerShared/Scenarios/Scenarios.cs index 9022f53ee..559ec769f 100644 --- a/Assets/Scripts/ServerShared/Scenarios/Scenarios.cs +++ b/Assets/Scripts/ServerShared/Scenarios/Scenarios.cs @@ -9,6 +9,6 @@ public static class Scenarios public static readonly Scenario[] Tests = { - new DjinniShakedown(), new StarvedReactor(), new Arcs(), new Duel(), new LauncherAngles(), new WeaponFeel(), new LongHaul(), new Pursuit(), new Crossing() + new DjinniShakedown(), new StarvedReactor(), new Arcs(), new Duel(), new LauncherAngles(), new WeaponFeel(), new LongHaul(), new Pursuit(), new Crossing(), new Belt() }; } diff --git a/tests/Aetheria.Shared.Tests/BeltScenarioTests.cs b/tests/Aetheria.Shared.Tests/BeltScenarioTests.cs new file mode 100644 index 000000000..b075505ab --- /dev/null +++ b/tests/Aetheria.Shared.Tests/BeltScenarioTests.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using System.Linq; +using Xunit; +using static CultMath.math; + +// The arena the operator flies to check mining target queries (map: Scenarios for operator checks, SC11 and SC14; ruling +// mining-merge-on-agent-proof). The test launches the scenario the way New Game does and reads what it staged. +public sealed partial class RunStartTests +{ + // The scan behind Belt's seed: seeds 1-256 of the demo cast's arena, no ambient traffic, the most asteroids in one belt + // per seed. Seed 24 holds 615; seed 1 holds 299. + private const int ScannedBeltAsteroids = 615; + + // Belt: the arena carries a belt of at least the scanned asteroid count, nothing else flies in it, the player stands + // 100 m outside the ring on the side nearest the origin and faces along it, and the player's sensors see rocks within + // mining reach from the first tick. + [Fact] + public void BeltConditions() + { + var (_, arena, staged, failures) = Launch(new Belt(), Inputs(() => GalaxySeed)); + Assert.True(failures.Count == 0, string.Join("; ", failures)); + Assert.Empty(staged.Entities); + Assert.Equal(new[] { staged.Player }, arena.Entities.OfType()); + + var belt = arena.Planets.Values.OfType().OrderByDescending(candidate => candidate.Asteroids.Length).First(); + Assert.True(belt.Asteroids.Length >= ScannedBeltAsteroids, $"the biggest belt has {belt.Asteroids.Length} asteroids"); + + var player = staged.Player; + var orbit = arena.Orbits[belt.Orbit.Key].Data; + var centre = arena.GetOrbitPosition(orbit.Parent.Key); + var radial = player.Position.xz - centre; + Assert.InRange(length(radial), orbit.Distance + 99f, orbit.Distance + 101f); + Assert.True(length(player.Position.xz) < length(centre), "the player stands on the side of the ring nearest the origin"); + Assert.True(abs(dot(player.Direction, normalize(radial))) < .01f, "the player faces along the ring"); + + var field = arena.Planets.Single(body => body.Value == belt).Key; + var inReach = new List(); + player.VisibleChunksInReach(inReach); + Assert.NotEmpty(inReach); + Assert.All(inReach, chunk => Assert.Equal(field, chunk.Field)); + } +}