From 6f31375def78a51cb82006c5a3513835e112761f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 00:40:59 +0200 Subject: [PATCH] Flight: a member's friendly override keeps it from following a flightmate's track; consumable-ai fixture orbit built on the zone The union picture stays the flight's; the per-member override is read where the member chooses its bearing. A first version dropped the track from the whole picture and silenced a hostile unaffiliated flightmate (SmokeRoundsStepped AiFusedDiscipline). Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Agents/Flight.cs | 8 +++----- tests/Aetheria.Shared.Tests/ConsumableAiTests.cs | 7 +++---- tests/Aetheria.Shared.Tests/FlightTests.cs | 15 ++++++++------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/ServerShared/Agents/Flight.cs b/Assets/Scripts/ServerShared/Agents/Flight.cs index 0b77e9aad..1fe54844b 100644 --- a/Assets/Scripts/ServerShared/Agents/Flight.cs +++ b/Assets/Scripts/ServerShared/Agents/Flight.cs @@ -60,10 +60,7 @@ public class Flight public void Update(float dt) { _time += dt; - // A track any member has made friendly (a truce override) is not the flight's to engage or follow, though a flightmate - // still senses it as hostile: the overrides are per member, so the picture is where they meet. - var picture = _members.SelectMany(m => m.Agent.Ship.VisibleEnemies).Distinct() - .Where(e => !_members.Any(m => m.Agent.Ship.IffOverride(e) == false)).ToList(); + var picture = _members.SelectMany(m => m.Agent.Ship.VisibleEnemies).Distinct().ToList(); foreach (var gone in _tracks.Keys.Where(t => !picture.Contains(t)).ToList()) _tracks.Remove(gone); foreach (var entity in picture) @@ -156,7 +153,8 @@ public class Flight // No engaged track in this member's own sensors: it steers on the flight's picture, a bearing and never targeting // data (ruling shared-track-bearing-only). That is the hailed and the complied, and an engaged track only a flightmate sees. Aim(ship, null); - var held = picture.Where(e => _tracks[e].Phase != Phase.None).ToList(); + // Overrides are per member: a flightmate's hostile track is not one this member follows after it has made it friendly. + var held = picture.Where(e => _tracks[e].Phase != Phase.None && ship.IffOverride(e) != false).ToList(); if (held.Count > 0) { // An engaged track outranks a hailed one; the held anchor is kept only while nothing outranks it. diff --git a/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs b/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs index 46439667b..1d723812a 100644 --- a/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs +++ b/tests/Aetheria.Shared.Tests/ConsumableAiTests.cs @@ -150,10 +150,7 @@ public sealed class ConsumableAiTests : IDisposable var maker = cache.RefOf(cache.GetByName("Maker")); EquippableItem Make(string name) where T : CraftedItemData => (EquippableItem) items.CreateInstance(items.CreateLot(cache.GetByName(name), maker, .5f)); - // One fixed orbit far from the fight: a pilot that is not engaged patrols it, as production's would. - var pack = new ZonePack(); - pack.Orbits.Add(cache.Upsert(new OrbitData { FixedPosition = float2(0, 5000) })); - var zone = new Zone(items, new PlanetSettings(), pack, new GalaxyZone { Name = "Test Zone", Owner = null }, null); + var zone = new Zone(items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = "Test Zone", Owner = null }, null); Ship NewShip(string gear) { var ship = new Ship(items, zone, Make("Skiff"), new EntitySettings()) @@ -176,6 +173,8 @@ public sealed class ConsumableAiTests : IDisposable scene.Hold = scene.Agent.CargoBays.Single(); // The agent joins as the zone admits a piloted ship (its Minion and CombatState come from production); the // locker is a gun ship nobody pilots. + // One fixed orbit far from the fight, before the agent joins: a pilot that is not engaged patrols it, as production's would. + zone.Orbits.Add(new CultRecordKey("test-orbit"), new Orbit(new OrbitData { FixedPosition = float2(0, 5000) })); zone.Admit(scene.Agent, piloted: true); zone.Admit(scene.Prey, piloted: false); zone.Admit(scene.Locker, piloted: false); diff --git a/tests/Aetheria.Shared.Tests/FlightTests.cs b/tests/Aetheria.Shared.Tests/FlightTests.cs index 21b65ad41..fb7d2406f 100644 --- a/tests/Aetheria.Shared.Tests/FlightTests.cs +++ b/tests/Aetheria.Shared.Tests/FlightTests.cs @@ -384,15 +384,16 @@ public sealed class FlightTests : IDisposable Assert.Equal(_items.GameplaySettings.AgentMinHitProbability, combatant.MinHitProbability); } - // The picture is the union of the members' senses while overrides are per member: a track one member has made - // friendly (a truce) is out of the flight's picture though a flightmate senses it as hostile. Kills: the friendly - // override ignored when the picture is built. + // The picture is the union of the members' senses while overrides are per member: a flightmate engages a track + // that a member has made friendly (a truce), and that member neither targets it nor follows its bearing. A truce is + // no grudge, in either order of building. Kills: the member's own friendly override ignored when it holds a bearing, + // or read as a grudge. [Theory] [InlineData(EngageOn.Detection, true)] [InlineData(EngageOn.Detection, false)] [InlineData(EngageOn.Provoked, true)] [InlineData(EngageOn.Provoked, false)] - public void ATrackAMemberHasMadeFriendlyIsNotEngagedByTheFlight(EngageOn on, bool friendlyBuiltFirst) + public void ATrackAMemberHasMadeFriendlyIsNeitherTargetedNorFollowedByIt(EngageOn on, bool friendlyBuiltFirst) { var faction = WithDoctrine(on); Ship friendly, sees; @@ -404,9 +405,9 @@ public sealed class FlightTests : IDisposable Tick(.1f); - Assert.True(sees.Target.Value.IsNone); + Assert.Same(on == EngageOn.Detection ? track : null, sees.Target.Value.Entity); Assert.True(friendly.Target.Value.IsNone); - Assert.Equal(Flight.Phase.None, _zone.Flights.Single(f => f.Contains(_zone.Agents.Single(a => a.Ship == sees))).PhaseOf(track)); + Assert.IsType(_zone.Agents.Single(a => a.Ship == friendly).Task); } [Fact] @@ -864,7 +865,7 @@ public sealed class FlightTests : IDisposable var (turn, thrust, _) = Follow(new float2(vx, vy), 100, new float2(fx, fy)); Assert.Equal(turns, turn != 0f); - Assert.NotEqual(new float2(0, 0), thrust); + if (!turns) Assert.NotEqual(new float2(0, 0), thrust); } // The pull toward a stationary anchor is the error over the standoff, as a fraction of the pilot's top speed: a