Merge gravity-fog-precision-and-jitter
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
49e8ea58e1
13 changed files with 129 additions and 22 deletions
|
|
@ -84,12 +84,12 @@ public sealed class FireControlPerWeaponTests : IDisposable
|
|||
(ItemRotation Rotation, float Arc)[] mounts = null, bool beam = false, WeaponFuse? fuse = null, float blast = 0f,
|
||||
float range = 100f, float targetRange = 60f, float accuracy = 1f, float minHit = .2f, bool lockWeapon = false,
|
||||
bool turret = false, float energy = 0f, float heat = 0f, float visibility = 0f, int magazine = 0, bool singleAmmoBurst = false, bool decoy = false, bool charged = false, bool auto = false,
|
||||
float effective = float.PositiveInfinity, float damageAtMax = 0f)
|
||||
float effective = float.PositiveInfinity, float damageAtMax = 0f, float velocity = 0f, float targetGridOffset = 0f)
|
||||
{
|
||||
mounts ??= new[] { (ItemRotation.None, 0f) };
|
||||
var hullData = new HullData
|
||||
{
|
||||
Name = "Hull", HullType = HullType.Ship, Shape = SolidShape(5, 4), Durability = 1000000, Mass = 1000, Armor = 0,
|
||||
Name = "Hull", HullType = HullType.Ship, Shape = SolidShape(5, 4), Durability = 1000000, Mass = 1000, Armor = 0, GridOffset = targetGridOffset,
|
||||
Hardpoints = { new HardpointData { Type = HardpointType.Sensors, Position = new int2(0, 0), Shape = new Shape() } }
|
||||
};
|
||||
var shooterHullData = new HullData
|
||||
|
|
@ -135,7 +135,7 @@ public sealed class FireControlPerWeaponTests : IDisposable
|
|||
behavior.MinRange = Constant(0);
|
||||
behavior.EffectiveRange = Constant(effective);
|
||||
behavior.DamageAtMaxRange = damageAtMax;
|
||||
behavior.Velocity = Constant(0);
|
||||
behavior.Velocity = Constant(velocity);
|
||||
behavior.Spread = Constant(0);
|
||||
behavior.DamageSpread = Constant(0);
|
||||
behavior.Penetration = Constant(0);
|
||||
|
|
@ -308,6 +308,39 @@ public sealed class FireControlPerWeaponTests : IDisposable
|
|||
Assert.True(r.Gun.Weapon.Firing, "the turret must fire a fused weapon at a designated target out of arc");
|
||||
}
|
||||
|
||||
// The AI aims at the height a target rides at (Entity.RideHeight: field plus the hull's GridOffset), not at the
|
||||
// plane. A target hull raised 40 u, a shot fast enough to be predicted: the turret's and Combat's aim point at the
|
||||
// target's stepped pose. Kills: either aim site spelling its own offset (dropped, added to, or scaled).
|
||||
[Fact]
|
||||
public void ATurretAimsAtTheHeightATargetRidesAt()
|
||||
{
|
||||
var r = Build(turret: true, velocity: 500f, targetGridOffset: 40f);
|
||||
r.Zone.Update(1f);
|
||||
|
||||
AssertAimsAtTarget(r);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CombatAimsAtTheHeightATargetRidesAt()
|
||||
{
|
||||
var r = Build(velocity: 500f, targetGridOffset: 40f);
|
||||
r.Zone.Agents.Add(new Minion(r.Shooter));
|
||||
r.Zone.Update(1f);
|
||||
r.Zone.Update(1f);
|
||||
|
||||
AssertAimsAtTarget(r);
|
||||
}
|
||||
|
||||
private static void AssertAimsAtTarget(Rig r)
|
||||
{
|
||||
var toTarget = r.Target.Position - r.Shooter.Position;
|
||||
Assert.True(abs(toTarget.y) > 30f, "fixture: the raised hull is well above the shooter");
|
||||
var expected = normalize(toTarget);
|
||||
Assert.Equal(expected.x, r.Shooter.Aim.x, 3);
|
||||
Assert.Equal(expected.y, r.Shooter.Aim.y, 3);
|
||||
Assert.Equal(expected.z, r.Shooter.Aim.z, 3);
|
||||
}
|
||||
|
||||
public enum Withheld { NoTarget, OutOfRange, NotVisible, Unlocked }
|
||||
|
||||
// The AI never fires a fused weapon at nothing: a missing target, one out of range, one not visible and one
|
||||
|
|
|
|||
|
|
@ -45,13 +45,13 @@ public sealed class FireControlTests : IDisposable
|
|||
|
||||
// `well` digs the zone one well at the origin (WellFixture), so heights differ across the zone.
|
||||
private (ItemManager items, Ship ship, EquippedItem[] weapons) BuildShipWithHardpoints(
|
||||
bool well, (ItemRotation rotation, float firingArc)[] hardpoints)
|
||||
bool well, (ItemRotation rotation, float firingArc)[] hardpoints, float gridOffset = 0f)
|
||||
{
|
||||
var hullShape = new Shape(Math.Max(hardpoints.Length, 3), 3);
|
||||
foreach (var cell in hullShape.AllCoordinates) hullShape[cell] = true;
|
||||
// Mass defaults to 0 (ItemData.cs:285), which zeroes ThermalMass (Entity.cs MapEntity) and NaNs
|
||||
// UpdateTemperature -- author a real mass so the entity's own temperature stays a real number.
|
||||
var hullData = new HullData { Name = "TestHull", HullType = HullType.Ship, Shape = hullShape, Durability = 1, Mass = 1000 };
|
||||
var hullData = new HullData { Name = "TestHull", HullType = HullType.Ship, Shape = hullShape, Durability = 1, Mass = 1000, GridOffset = gridOffset };
|
||||
for (var i = 0; i < hardpoints.Length; i++)
|
||||
hullData.Hardpoints.Add(new HardpointData
|
||||
{
|
||||
|
|
@ -380,6 +380,39 @@ public sealed class FireControlTests : IDisposable
|
|||
// height, so its distance in space is longer than its planar distance. A claim whose Range lies between the two, full
|
||||
// damage out to the planar distance, is in range on the plane and out of range in space: it (against Slug's 5) is the
|
||||
// chosen claim. Mutation: Combat measures the three-dimensional distance (the claim then reads 0).
|
||||
// B32: a ship drawn ahead rides the field at its drawn xz, not at the height of its last step (the per-step height
|
||||
// staircase that read as jitter on a steep slope). Mutation: DrawAhead's y back to entity.Position.y fails the first
|
||||
// assertion; reading the height at the last step's xz fails it too.
|
||||
[Fact]
|
||||
public void ADrawnShipRidesTheFieldAtItsDrawnPosition()
|
||||
{
|
||||
var (items, ship, _) = BuildShipWithHardpoints(true, new[] { (ItemRotation.None, 0f) }, gridOffset: 2.5f);
|
||||
var zone = ship.Zone;
|
||||
ship.Position = float3(200, 0, 0);
|
||||
zone.Update(1f);
|
||||
ship.Velocity = float2(100, 0); // up the slope, away from the well
|
||||
const float lead = .1f;
|
||||
|
||||
var drawn = DrawAhead.Position(ship, lead);
|
||||
|
||||
Assert.Equal(ship.Position.x + 100 * lead, drawn.x, 4);
|
||||
// The hull rides 2.5 u above the field (authored above): dropping or doubling the offset moves the ship by 2.5.
|
||||
Assert.Equal(zone.GetHeight(float2(drawn.x, drawn.z)) + 2.5f, drawn.y, 4);
|
||||
Assert.Equal(zone.GetHeight(float2(ship.Position.x, ship.Position.z)) + 2.5f, ship.Position.y, 4);
|
||||
Assert.True(abs(drawn.y - ship.Position.y) > .1f, "the slope is real: the drawn height differs from the last step's");
|
||||
var still = DrawAhead.Position(ship, 0f);
|
||||
Assert.Equal(ship.Position.x, still.x);
|
||||
Assert.Equal(ship.Position.y, still.y);
|
||||
Assert.Equal(ship.Position.z, still.z);
|
||||
|
||||
// A child (a docked ship) is drawn where its parent is drawn, whatever its own pose and velocity.
|
||||
var child = new Ship(items, zone, ship.Hull, new EntitySettings()) { Position = float3(-500, 7, 300), Velocity = float2(-30, 40), Parent = ship };
|
||||
var carried = DrawAhead.Position(child, lead);
|
||||
Assert.Equal(drawn.x, carried.x, 4);
|
||||
Assert.Equal(drawn.y, carried.y, 4);
|
||||
Assert.Equal(drawn.z, carried.z, 4);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheAIMeasuresTheTargetOnTheGroundPlane()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ public sealed partial class RunStartTests
|
|||
const float lead = .007f;
|
||||
var ahead = DrawAhead.Position(player, lead);
|
||||
Assert.Equal(player.Position.x + player.Velocity.x * lead, ahead.x, 6);
|
||||
Assert.Equal(player.Position.y, ahead.y);
|
||||
Assert.Equal(player.RideHeight(float2(ahead.x, ahead.z)), ahead.y, 4);
|
||||
Assert.Equal(player.Position.z + player.Velocity.y * lead, ahead.z, 6);
|
||||
Assert.Equal(before, Snapshot(arena, new List<string>()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue