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 <noreply@anthropic.com>
This commit is contained in:
parent
b08f7d80ae
commit
6f31375def
3 changed files with 14 additions and 16 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -150,10 +150,7 @@ public sealed class ConsumableAiTests : IDisposable
|
|||
var maker = cache.RefOf(cache.GetByName<Faction>("Maker"));
|
||||
EquippableItem Make<T>(string name) where T : CraftedItemData =>
|
||||
(EquippableItem) items.CreateInstance(items.CreateLot(cache.GetByName<T>(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<HullData>("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);
|
||||
|
|
|
|||
|
|
@ -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<PatrolOrbitsTask>(_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
|
||||
|
|
|
|||
Loading…
Reference in a new issue