diff --git a/tests/Aetheria.Shared.Tests/MineTests.cs b/tests/Aetheria.Shared.Tests/MineTests.cs index ba3c0f0d5..358862397 100644 --- a/tests/Aetheria.Shared.Tests/MineTests.cs +++ b/tests/Aetheria.Shared.Tests/MineTests.cs @@ -446,6 +446,22 @@ public sealed class MineTests : IDisposable Assert.True(shipsA[4].Hull.Durability < 1000000f); } + // The trigger gate never arcs a mine layer (FireControl.ArcPermitsFire): it lays a body, not a round, so a cursor + // outside its arc still lays. The layer is unfused (no Fuse), so the fused exemption cannot cover it and only the + // mine-layer exemption can; the fixture checks the aim is outside the arc and the gate would hold any other gun. + [Fact] + public void AMineLayerLaysWithTheAimOutsideItsArc() + { + var lab = Build(fuseKind: null); + Assert.Null(FireControl.FuseOf(lab.WeaponItem, out _)); + var mount = FireControl.MountDirection(lab.WeaponItem); + lab.Layer.Aim = -mount; + Assert.False(FireControl.InArc(lab.WeaponItem, lab.Layer.Aim), "fixture: the aim must be outside the arc"); + + Assert.True(FireControl.ArcPermitsFire(lab.Weapon, lab.Layer)); + LayOne(lab); + } + [Fact] public void LayingFiresNoShot() { diff --git a/tests/Aetheria.Shared.Tests/SolutionTests.cs b/tests/Aetheria.Shared.Tests/SolutionTests.cs index 4418569c7..23536a18f 100644 --- a/tests/Aetheria.Shared.Tests/SolutionTests.cs +++ b/tests/Aetheria.Shared.Tests/SolutionTests.cs @@ -71,6 +71,7 @@ public sealed partial class FireControlCut124Tests Assert.True(solution.Free); Assert.True(FireControl.ArcPermitsFire(e.Weapon, e.Shooter)); Near(float2(0, 1), solution.Direction); + Assert.Same(e.Target, solution.Subject); Assert.Equal(0f, FireControl.HitProbability(e.Weapon, e.Shooter, e.Target)); } @@ -177,4 +178,33 @@ public sealed partial class FireControlCut124Tests Assert.True(FireControl.AgentFires(e.Weapon, e.Shooter, e.Target)); Near(intercept, solution.Direction); } + + // Solve flies along the solution against the target it is given, not the shooter's designated one (the HUD forecast + // and an agent's burst ask about other entities). A decoy 40 degrees off, in the same zone, is passed while the + // designated target sits dead ahead; the round goes to the decoy's intercept. Kills a Solve that reads the shooter's + // target, a constant, or a swapped argument; the fixture checks the two intercepts differ. + [Fact] + public void SolveFliesToTheTargetItIsGiven() + { + var e = Build(TestSettings(), SolidShape(5, 4), hardpointArc: SolutionArc, weaponRange: 200f); + var hull = e.Items.ItemData.RefOf(e.HullData); + var decoy = new Ship(e.Items, e.Zone, new EquippableItem { Data = hull, Durability = 1000000, Lot = 9000 }, new EntitySettings()); + e.Zone.Entities.Add(decoy); + decoy.Activate(); + var at = radians(40f); + decoy.Position = e.Shooter.Position + float3(sin(at), 0, cos(at)) * 100f; + e.Shooter.VisibleEntities.Add(decoy); + e.Shooter.EntityInfoGathered[decoy] = 1f; + e.Shooter.SetIff(decoy, true); + Aim(e, float2(0, -1)); + + var designated = FireControl.Solution(e.Weapon, e.Shooter, e.Target).Direction; + var other = FireControl.Solution(e.Weapon, e.Shooter, decoy).Direction; + Assert.True(FireControl.Bears(e.Weapon, e.Shooter, decoy, out _)); + Assert.True(length(designated - other) > .3f, "fixture: the two intercepts must differ"); + Assert.Same(e.Target, e.Shooter.Target.Value.Entity); + + Near(other, FireControl.Solve(e.Weapon, e.WeaponItem, e.Shooter, decoy).TravelDirection); + Near(designated, FireControl.Solve(e.Weapon, e.WeaponItem, e.Shooter, e.Target).TravelDirection); + } }