Wire client VTOL/arc HUD & inputs and add Cut 3a tests
This commit is contained in:
parent
95bbca6499
commit
eb579a6ede
10 changed files with 552 additions and 86 deletions
|
|
@ -42,7 +42,7 @@ namespace RustToDust.Tests
|
|||
Assert.True(displacement > 10f, $"Expected >10m displacement, got {displacement:F2}m");
|
||||
Assert.True(yawDelta > 0.2f, $"Expected yaw change >0.2 rad, got {yawDelta:F2} rad");
|
||||
|
||||
var weapon = player.Grid.GetMountedOn("wpn_roof");
|
||||
var weapon = player.Grid.GetMountedOn("hp.weapon.roof");
|
||||
Assert.NotNull(weapon);
|
||||
Assert.True(weapon!.CurrentTemp > ChassisGrid.AmbientTemp + 5f);
|
||||
Assert.True(tracerTicks > 0);
|
||||
|
|
@ -103,10 +103,10 @@ namespace RustToDust.Tests
|
|||
using var session = new ArenaSession(seed: 19);
|
||||
var player = session.State.Player;
|
||||
|
||||
// Swap to Tank (HalfWidth = 1.65m, HalfLength = 2.65m) where broadside vs forward differs by 1.0m.
|
||||
// Swap to Tank / Anvil (HalfWidth = 1.93m, HalfLength = 2.83m) where broadside vs forward differs by ~0.9m.
|
||||
session.State.SpawnChassisDrop(player.X + 0.5f, player.Z + 0.5f, Catalog.Tank);
|
||||
Assert.True(session.TrySwapNearbyChassis());
|
||||
Assert.Equal("tank", player.Grid.Spec.Id);
|
||||
Assert.Equal(Catalog.Tank.Id, player.Grid.Spec.Id);
|
||||
|
||||
// Step once to settle body, then aim strictly perpendicular (broadside) to player's Yaw.
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, false));
|
||||
|
|
|
|||
|
|
@ -131,6 +131,14 @@ namespace RustToDust.Tests
|
|||
var player = session.State.Player;
|
||||
var rival = session.State.Contenders[1];
|
||||
|
||||
// Ensure rival is a low-profile ground vehicle shorter than the 4m ruin cover wall
|
||||
if (rival.Grid.Spec.IsVtol || rival.Grid.Spec.HalfHeight * 2f >= box.HalfY * 2f)
|
||||
{
|
||||
session.SetContenderPose(rival.Id, box.X, box.Z + box.HalfZ + 4f);
|
||||
session.State.SpawnChassisDrop(box.X, box.Z + box.HalfZ + 4f, Catalog.Jackal);
|
||||
Assert.True(session.State.TrySwapNearbyChassis(rival.Id));
|
||||
}
|
||||
|
||||
session.SetContenderPose(player.Id, box.X, box.Z - box.HalfZ - 4f);
|
||||
session.SetContenderPose(rival.Id, box.X, box.Z + box.HalfZ + 4f);
|
||||
|
||||
|
|
@ -227,7 +235,14 @@ namespace RustToDust.Tests
|
|||
var provokedSpec = tourists[0];
|
||||
var clearedSpec = tourists[1];
|
||||
|
||||
// Keep AI contenders safely inside the safe circle and other spectators far away so they don't kill player or steal clearance
|
||||
// Place player on the side of the mesa further from center (strictly outside SafeRadius)
|
||||
float xNeg = mesa.X - mesa.RadiusX - 18f;
|
||||
float xPos = mesa.X + mesa.RadiusX + 18f;
|
||||
bool negIsFurther = (xNeg * xNeg + mesa.Z * mesa.Z) >= (xPos * xPos + mesa.Z * mesa.Z);
|
||||
float occludedX = negIsFurther ? xNeg : xPos;
|
||||
float specSideX = negIsFurther ? (mesa.X + mesa.RadiusX + 45f) : (mesa.X - mesa.RadiusX - 45f);
|
||||
|
||||
// Keep AI contenders safely inside the safe circle and other spectators behind the mesa shadow so they don't peek around the flank
|
||||
for (int i = 1; i < session.State.Contenders.Count; i++)
|
||||
{
|
||||
session.SetContenderPose(session.State.Contenders[i].Id, (i - 6) * 12f, 0f);
|
||||
|
|
@ -237,17 +252,12 @@ namespace RustToDust.Tests
|
|||
var other = session.State.Spectators.Spectators[i];
|
||||
if (other.Id != provokedSpec.Id && other.Id != clearedSpec.Id)
|
||||
{
|
||||
session.SetSpectatorPose(other.Id, -mesa.X, -mesa.Z);
|
||||
float farX = (mesa.X >= 0f ? -1f : 1f) * 680f;
|
||||
float farZ = (mesa.Z >= 0f ? -1f : 1f) * 680f;
|
||||
session.SetSpectatorPose(other.Id, farX, farZ);
|
||||
}
|
||||
}
|
||||
|
||||
// Place player on the side of the mesa further from center (strictly outside SafeRadius)
|
||||
float xNeg = mesa.X - mesa.RadiusX - 18f;
|
||||
float xPos = mesa.X + mesa.RadiusX + 18f;
|
||||
bool negIsFurther = (xNeg * xNeg + mesa.Z * mesa.Z) >= (xPos * xPos + mesa.Z * mesa.Z);
|
||||
float occludedX = negIsFurther ? xNeg : xPos;
|
||||
float specSideX = negIsFurther ? (mesa.X + mesa.RadiusX + 45f) : (mesa.X - mesa.RadiusX - 45f);
|
||||
|
||||
// Briefly establish visual contact for provokedSpec at initial spot, then move player behind the mesa
|
||||
session.SetContenderPose(player.Id, specSideX - (negIsFurther ? 12f : -12f), mesa.Z);
|
||||
session.SetSpectatorPose(provokedSpec.Id, specSideX, mesa.Z);
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ namespace RustToDust.Tests
|
|||
public void Conduction_SpreadsHeatFromHotHardpointToNeighbors()
|
||||
{
|
||||
var grid = Catalog.CreateStarterBuggy();
|
||||
// wpn_roof is at (1, 0). Neighbor (0, 0) and (1, 1) start at ambient 20f.
|
||||
grid.InjectHardpointHeat("wpn_roof", 600f);
|
||||
// hp.weapon.roof is at (1, 0) 1x2. Neighbors (0, 0) and (1, 2) start at ambient 20f.
|
||||
grid.InjectHardpointHeat("hp.weapon.roof", 600f);
|
||||
float hotBefore = grid.Temperature[1, 0];
|
||||
Assert.True(hotBefore > ChassisGrid.AmbientTemp + 20f);
|
||||
Assert.Equal(ChassisGrid.AmbientTemp, grid.Temperature[0, 0]);
|
||||
Assert.Equal(ChassisGrid.AmbientTemp, grid.Temperature[1, 1]);
|
||||
Assert.Equal(ChassisGrid.AmbientTemp, grid.Temperature[1, 2]);
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
|
|
@ -23,7 +23,7 @@ namespace RustToDust.Tests
|
|||
}
|
||||
|
||||
Assert.True(grid.Temperature[0, 0] > ChassisGrid.AmbientTemp + 1f);
|
||||
Assert.True(grid.Temperature[1, 1] > ChassisGrid.AmbientTemp + 1f);
|
||||
Assert.True(grid.Temperature[1, 2] > ChassisGrid.AmbientTemp + 1f);
|
||||
Assert.True(grid.Temperature[1, 0] < hotBefore);
|
||||
}
|
||||
|
||||
|
|
@ -99,29 +99,31 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void LooseFitAndSwapChassis_PreservesCompatibleGearAndStowsOverflow()
|
||||
{
|
||||
// Tank has 2x2 turret hardpoint: smaller 1x1 weapon fits loosely; 2x2 weapon must NOT fit 1x1 buggy roof.
|
||||
var tankGrid = new ChassisGrid(Catalog.Tank);
|
||||
Assert.True(tankGrid.TryMount(Catalog.Recoilless, "wpn_turret")); // 2x2 into 2x2
|
||||
Assert.True(tankGrid.TryMount(Catalog.Mg762, "wpn_coax")); // 1x1 into 1x1
|
||||
Assert.True(tankGrid.TryMount(Catalog.TurboCore, "eng_rear")); // 1x2 into 2x2
|
||||
Assert.True(tankGrid.TryMount(Catalog.GoldRadiator, "rad_deck")); // 1x1 into 1x1
|
||||
Assert.True(tankGrid.TryMount(Catalog.WeldedPlate, "arm_glacis")); // 1x1 into 2x1
|
||||
Assert.True(tankGrid.TryMount(Catalog.GildedPlate, "arm_skirt")); // 1x1 into 1x1
|
||||
// Ironclad has 2x2 main turret hardpoint: smaller 1x1 weapon fits loosely; 2x2 weapon must NOT fit 1x2 Jackal roof.
|
||||
var tankGrid = new ChassisGrid(Catalog.Ironclad);
|
||||
Assert.True(tankGrid.TryMount(Catalog.Recoilless, "hp.weapon.main")); // 2x2 into 2x2
|
||||
Assert.True(tankGrid.TryMount(Catalog.Mg762, "hp.weapon.coax")); // 1x1 into 1x1
|
||||
Assert.True(tankGrid.TryMount(Catalog.TurboCore, "hp.engine.rear")); // 1x2 into 2x2
|
||||
Assert.True(tankGrid.TryMount(Catalog.GoldRadiator, "hp.radiator.l")); // 1x1 into 1x2
|
||||
Assert.True(tankGrid.TryMount(Catalog.WeldedPlate, "hp.armor.front")); // 1x1 into 4x1
|
||||
Assert.True(tankGrid.TryMount(Catalog.GildedPlate, "hp.armor.skirts")); // 1x1 into 1x2
|
||||
|
||||
// Fill cargo near buggy capacity (4) so swapping down to Buggy overflows to ground!
|
||||
// Fill cargo so swapping down to Jackal (capacity 4) overflows 2 items to ground!
|
||||
Assert.True(tankGrid.TryAddCargo(Catalog.Flak));
|
||||
Assert.True(tankGrid.TryAddCargo(Catalog.CopperRad));
|
||||
Assert.True(tankGrid.TryAddCargo(Catalog.DieselCore));
|
||||
|
||||
List<ModuleSpec> dropped = tankGrid.SwapChassis(Catalog.Buggy);
|
||||
List<ModuleSpec> dropped = tankGrid.SwapChassis(Catalog.Jackal);
|
||||
|
||||
// Buggy has 1x1 Weapon (mg_762 fits, recoilless 2x2 does not!), 1x1 Engine (turbo_core 1x2 does not fit!), 1x1 Radiator (gold_radiator fits!), 0 Armor hardpoints.
|
||||
Assert.Equal("buggy", tankGrid.Spec.Id);
|
||||
// Jackal has 1x2 Weapon (mg_762 fits, recoilless 2x2 does not!), 1x2 Engine (turbo_core fits), 1x1 Radiator (gold_radiator fits), 0 Armor hardpoints.
|
||||
Assert.Equal("jackal", tankGrid.Spec.Id);
|
||||
Assert.Contains(tankGrid.Mounted, m => m.Spec.Id == "mg_762");
|
||||
Assert.Contains(tankGrid.Mounted, m => m.Spec.Id == "turbo_core");
|
||||
Assert.Contains(tankGrid.Mounted, m => m.Spec.Id == "gold_radiator");
|
||||
Assert.DoesNotContain(tankGrid.Mounted, m => m.Spec.Id == "recoilless");
|
||||
|
||||
// 6 mounted on Tank: 2 transferred (mg_762, gold_radiator), 4 leftover + 2 cargo = 6 items -> 4 in Buggy Cargo, 2 dropped!
|
||||
Assert.Equal(Catalog.Buggy.CargoCapacity, tankGrid.Cargo.Count);
|
||||
// 6 mounted on Ironclad: 3 transferred, 3 leftover + 3 cargo = 6 items -> 4 in Jackal Cargo, 2 dropped!
|
||||
Assert.Equal(Catalog.Jackal.CargoCapacity, tankGrid.Cargo.Count);
|
||||
Assert.Equal(2, dropped.Count);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -382,13 +382,15 @@ namespace RustToDust.Tests
|
|||
float climbProgress = maxGroundY - startGroundY;
|
||||
float minRequiredClimb = testDune ? 4.0f : 2.0f;
|
||||
float minAllowedUpDot = chassis.IsWalker ? 0.927f : 0.50f;
|
||||
// VTOLs naturally hover at ~3m AGL and briefly exceed 5m AGL when crossing sharp dune crests at speed
|
||||
float maxAllowedAirGap = chassis.IsVtol ? 10.5f : 5.0f;
|
||||
|
||||
Assert.True(climbProgress >= minRequiredClimb,
|
||||
$"Insufficient uphill climb progress (seed={seed}, chassis={chassis.Id}, dune={testDune}): climb={climbProgress:F2}m start=({startX:F1},{startZ:F1},h={startGroundY:F2}) end=({player.X:F1},{player.Z:F1},maxH={maxGroundY:F2}) brush=({targetBrush.X:F1},{targetBrush.Z:F1},rx={targetBrush.RadiusX:F1},rz={targetBrush.RadiusZ:F1},rot={targetBrush.RotationRad:F2},dh={targetBrush.HeightDelta:F1})");
|
||||
Assert.True(minBottomRel >= -0.35f,
|
||||
$"Terrain tunneling detected (seed={seed}, chassis={chassis.Id}, dune={testDune}): minBottomRel={minBottomRel:F2}m");
|
||||
Assert.True(maxAirGap <= 5.0f,
|
||||
$"Excessive sky launch detected (seed={seed}, chassis={chassis.Id}, dune={testDune}): maxAirGap={maxAirGap:F2}m");
|
||||
Assert.True(maxAirGap <= maxAllowedAirGap,
|
||||
$"Excessive sky launch detected (seed={seed}, chassis={chassis.Id}, dune={testDune}): maxAirGap={maxAirGap:F2}m (max={maxAllowedAirGap:F1}m)");
|
||||
Assert.True(minUpDot >= minAllowedUpDot,
|
||||
$"Excessive chassis tilt (seed={seed}, chassis={chassis.Id}, dune={testDune}): minUpDot={minUpDot:F3} (req>={minAllowedUpDot:F3})");
|
||||
}
|
||||
|
|
|
|||
134
tests/RustToDust.Tests/VehiclePackageTests.cs
Normal file
134
tests/RustToDust.Tests/VehiclePackageTests.cs
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using RustToDust.Core;
|
||||
using Xunit;
|
||||
|
||||
namespace RustToDust.Tests
|
||||
{
|
||||
public sealed class VehiclePackageTests
|
||||
{
|
||||
private static readonly string[] Expected15Ids =
|
||||
{
|
||||
"jackal", "mule", "ferret", "hornet", "mammoth",
|
||||
"ironclad", "anvil", "condor", "breaker", "paladin",
|
||||
"raptor", "manticore", "bastion", "spectre", "kestrel"
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void All15VehicleArchives_LoadFromCultCacheAndMatchManifests()
|
||||
{
|
||||
Assert.Equal(15, Catalog.AllChassis.Count);
|
||||
Assert.Equal(15, Catalog.PackagesById.Count);
|
||||
|
||||
string vehiclesRoot = VehicleCatalogLoader.LocateVehiclesDirectory();
|
||||
foreach (string id in Expected15Ids)
|
||||
{
|
||||
string ccPath = Path.Combine(vehiclesRoot, id, "vehicle.cc");
|
||||
string manifestPath = Path.Combine(vehiclesRoot, id, "manifest.json");
|
||||
Assert.True(File.Exists(ccPath), $"Missing vehicle.cc for {id}");
|
||||
Assert.True(File.Exists(manifestPath), $"Missing manifest.json for {id}");
|
||||
|
||||
VehiclePackage pkg = VehiclePackageStore.Read(ccPath);
|
||||
Assert.Equal(id, pkg.Id);
|
||||
Assert.True(File.Exists(Path.Combine(vehiclesRoot, id, pkg.ModelAsset)), $"Missing GLB {pkg.ModelAsset}");
|
||||
|
||||
using var doc = JsonDocument.Parse(File.ReadAllText(manifestPath));
|
||||
var root = doc.RootElement;
|
||||
|
||||
Assert.Equal(root.GetProperty("gridWidth").GetInt32(), pkg.GridWidth);
|
||||
Assert.Equal(root.GetProperty("gridHeight").GetInt32(), pkg.GridHeight);
|
||||
|
||||
var manifestHps = root.GetProperty("hardpoints").EnumerateArray().ToArray();
|
||||
Assert.Equal(manifestHps.Length, pkg.Hardpoints.Count);
|
||||
for (int i = 0; i < manifestHps.Length; i++)
|
||||
{
|
||||
string expectedId = manifestHps[i].GetProperty("id").GetString()!;
|
||||
string expectedAnchor = manifestHps[i].GetProperty("modelNodeId").GetString()!;
|
||||
Assert.Equal(expectedId, pkg.Hardpoints[i].Id);
|
||||
Assert.Equal(expectedAnchor, pkg.Hardpoints[i].AnchorId);
|
||||
}
|
||||
|
||||
var manifestJoints = root.GetProperty("joints").EnumerateArray().ToArray();
|
||||
Assert.Equal(manifestJoints.Length, pkg.Joints.Count);
|
||||
for (int i = 0; i < manifestJoints.Length; i++)
|
||||
{
|
||||
Assert.Equal(manifestJoints[i].GetProperty("id").GetString(), pkg.Joints[i].Id);
|
||||
}
|
||||
|
||||
var boundsSize = root.GetProperty("bounds").GetProperty("size").EnumerateArray().Select(e => e.GetSingle()).ToArray();
|
||||
Assert.Equal(boundsSize[0] * 0.5f, pkg.HalfWidth, precision: 3);
|
||||
Assert.Equal(boundsSize[1] * 0.5f, pkg.HalfHeight, precision: 3);
|
||||
Assert.Equal(boundsSize[2] * 0.5f, pkg.HalfLength, precision: 3);
|
||||
|
||||
Assert.NotEmpty(pkg.PartCells);
|
||||
var spec = pkg.ToChassisSpec();
|
||||
Assert.All(pkg.PartCells, pc =>
|
||||
{
|
||||
Assert.False(string.IsNullOrWhiteSpace(pc.NodeName));
|
||||
Assert.True(spec.IsActive(pc.CellX, pc.CellY), $"{id}: PartCell '{pc.NodeName}' mapped to inactive ({pc.CellX},{pc.CellY})");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BreakerArchive_RoundTripsFullMechanismHierarchy()
|
||||
{
|
||||
string vehiclesRoot = VehicleCatalogLoader.LocateVehiclesDirectory();
|
||||
string manifestPath = Path.Combine(vehiclesRoot, "breaker", "manifest.json");
|
||||
using var doc = JsonDocument.Parse(File.ReadAllText(manifestPath));
|
||||
var mechJson = doc.RootElement.GetProperty("mechanisms");
|
||||
|
||||
var breaker = Catalog.PackagesById["breaker"];
|
||||
Assert.NotNull(breaker.Mechanisms);
|
||||
Assert.Equal(mechJson.GetProperty("dofs").GetArrayLength(), breaker.Mechanisms!.Dofs.Count);
|
||||
Assert.Equal(35, breaker.Mechanisms.Dofs.Count);
|
||||
Assert.Equal(mechJson.GetProperty("rams").GetArrayLength(), breaker.Mechanisms.Rams.Count);
|
||||
Assert.Equal(2, breaker.Mechanisms.Scissors.Count);
|
||||
Assert.Equal(2, breaker.Mechanisms.Struts.Count);
|
||||
|
||||
Assert.Equal("LegL.Hip", breaker.Mechanisms.Dofs[0].Name);
|
||||
Assert.Equal("LegL.Torque", breaker.Mechanisms.Scissors[0].Name);
|
||||
Assert.Equal("LegL.Oleo", breaker.Mechanisms.Struts[0].Name);
|
||||
Assert.Equal(0.2f, breaker.Mechanisms.Struts[0].Travel, precision: 4);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AliasesAndVtolBalance_MatchSpecification()
|
||||
{
|
||||
Assert.Same(Catalog.Jackal, Catalog.Buggy);
|
||||
Assert.Same(Catalog.Mule, Catalog.Technical);
|
||||
Assert.Same(Catalog.Anvil, Catalog.Tank);
|
||||
|
||||
// VTOL glass-cannon balance vs ground equivalents
|
||||
Assert.Equal(MobilityKind.Vtol, Catalog.Hornet.Mobility);
|
||||
Assert.Equal(MobilityKind.Vtol, Catalog.Condor.Mobility);
|
||||
Assert.Equal(42f, Catalog.Hornet.HoverMaxAltitudeM);
|
||||
Assert.Equal(36f, Catalog.Condor.HoverMaxAltitudeM);
|
||||
Assert.Equal(0f, Catalog.Jackal.HoverMaxAltitudeM);
|
||||
Assert.Equal(0f, Catalog.Anvil.HoverMaxAltitudeM);
|
||||
|
||||
Assert.True(Catalog.Hornet.BaseCellArmor < Catalog.Jackal.BaseCellArmor,
|
||||
$"Hornet armor ({Catalog.Hornet.BaseCellArmor}) must be lighter than Jackal ({Catalog.Jackal.BaseCellArmor})");
|
||||
Assert.True(Catalog.Hornet.BaseCellArmor < Catalog.Ferret.BaseCellArmor,
|
||||
$"Hornet armor ({Catalog.Hornet.BaseCellArmor}) must be lighter than Ferret ({Catalog.Ferret.BaseCellArmor})");
|
||||
Assert.True(Catalog.Condor.BaseCellArmor < Catalog.Ironclad.BaseCellArmor,
|
||||
$"Condor armor ({Catalog.Condor.BaseCellArmor}) must be lighter than Ironclad ({Catalog.Ironclad.BaseCellArmor})");
|
||||
Assert.True(Catalog.Condor.BaseCellArmor < Catalog.Anvil.BaseCellArmor,
|
||||
$"Condor armor ({Catalog.Condor.BaseCellArmor}) must be lighter than Anvil ({Catalog.Anvil.BaseCellArmor})");
|
||||
|
||||
// All 14 non-starter chassis spawn as salvageable drops in MatchState
|
||||
var state = new MatchState(seed: 42);
|
||||
var droppedChassisIds = state.GroundDrops
|
||||
.Where(d => d.Chassis is not null)
|
||||
.Select(d => d.Chassis!.Id)
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
foreach (string id in Expected15Ids.Where(x => x != "jackal"))
|
||||
{
|
||||
Assert.Contains(id, droppedChassisIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
258
tests/RustToDust.Tests/VtolAndArcTests.cs
Normal file
258
tests/RustToDust.Tests/VtolAndArcTests.cs
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using RustToDust.Core;
|
||||
using RustToDust.Ymir;
|
||||
using Xunit;
|
||||
|
||||
namespace RustToDust.Tests
|
||||
{
|
||||
public sealed class VtolAndArcTests
|
||||
{
|
||||
private static void IsolateContenders(ArenaSession session, params int[] keepIds)
|
||||
{
|
||||
var keep = keepIds.ToHashSet();
|
||||
for (int i = 0; i < session.State.Contenders.Count; i++)
|
||||
{
|
||||
var c = session.State.Contenders[i];
|
||||
if (!keep.Contains(c.Id))
|
||||
{
|
||||
session.SetContenderPose(c.Id, -650f + i * 10f, -650f);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < session.State.Spectators.Spectators.Count; i++)
|
||||
{
|
||||
var s = session.State.Spectators.Spectators[i];
|
||||
session.SetSpectatorPose(s.Id, 650f, -650f + i * 4f);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Vtol_HornetAndCondor_ClimbHoverAndDescendViaVerticalThrottle()
|
||||
{
|
||||
foreach (var vtolSpec in new[] { Catalog.Hornet, Catalog.Condor })
|
||||
{
|
||||
using var session = new ArenaSession(seed: 42);
|
||||
IsolateContenders(session, 0);
|
||||
var player = session.State.Player;
|
||||
session.SetContenderPose(player.Id, 0f, 0f, 0f);
|
||||
|
||||
session.State.SpawnChassisDrop(player.X, player.Z, vtolSpec);
|
||||
Assert.True(session.TrySwapNearbyChassis());
|
||||
Assert.Equal(vtolSpec.Id, player.Grid.Spec.Id);
|
||||
Assert.True(player.Grid.Spec.IsVtol);
|
||||
|
||||
float gh0 = session.State.Terrain.SampleHeight(player.X, player.Z);
|
||||
float initialAgl = player.Y - vtolSpec.HalfHeight - gh0;
|
||||
|
||||
// Climb with VerticalThrottle = +1 for 2.5s (150 ticks)
|
||||
for (int t = 0; t < 150; t++)
|
||||
{
|
||||
session.Step(new PlayerInput(0.4f, 0.1f, player.X, player.Z + 30f, false, false, false, VerticalThrottle: 1f));
|
||||
}
|
||||
|
||||
float ghClimbed = session.State.Terrain.SampleHeight(player.X, player.Z);
|
||||
float climbedAgl = player.Y - vtolSpec.HalfHeight - ghClimbed;
|
||||
Assert.True(climbedAgl > initialAgl + 12f,
|
||||
$"{vtolSpec.Id}: expected climb > 12m, got initial={initialAgl:F2}m -> climbed={climbedAgl:F2}m");
|
||||
Assert.True(climbedAgl <= vtolSpec.HoverMaxAltitudeM + 2.0f,
|
||||
$"{vtolSpec.Id}: exceeded HoverMaxAltitudeM {vtolSpec.HoverMaxAltitudeM}m (got {climbedAgl:F2}m)");
|
||||
|
||||
// Hold hover with VerticalThrottle = 0 for 2.0s (120 ticks) -> settles to TargetHoverAltAgl and holds steady
|
||||
for (int t = 0; t < 60; t++)
|
||||
{
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z + 30f, false, false, false, VerticalThrottle: 0f));
|
||||
}
|
||||
float ghSettled = session.State.Terrain.SampleHeight(player.X, player.Z);
|
||||
float settledAgl = player.Y - vtolSpec.HalfHeight - ghSettled;
|
||||
for (int t = 0; t < 60; t++)
|
||||
{
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z + 30f, false, false, false, VerticalThrottle: 0f));
|
||||
}
|
||||
float ghHeld = session.State.Terrain.SampleHeight(player.X, player.Z);
|
||||
float heldAgl = player.Y - vtolSpec.HalfHeight - ghHeld;
|
||||
Assert.InRange(heldAgl, player.TargetHoverAltAgl - 1.5f, player.TargetHoverAltAgl + 1.5f);
|
||||
Assert.InRange(heldAgl, settledAgl - 1.0f, settledAgl + 1.0f);
|
||||
|
||||
// Descend with VerticalThrottle = -1 for 3s (180 ticks) - should settle smoothly near 2.5m clearance
|
||||
for (int t = 0; t < 180; t++)
|
||||
{
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z + 30f, false, false, false, VerticalThrottle: -1f));
|
||||
}
|
||||
float ghDesc = session.State.Terrain.SampleHeight(player.X, player.Z);
|
||||
float descAgl = player.Y - vtolSpec.HalfHeight - ghDesc;
|
||||
Assert.True(descAgl < heldAgl - 8f, $"{vtolSpec.Id}: expected descent from {heldAgl:F2}m, got {descAgl:F2}m");
|
||||
Assert.InRange(descAgl, 1.5f, 4.5f);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MwllTriangle_ZenithBlindSpot_MainCannonBlocked_WideArcPdAndDistantGroundRigHit()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 42);
|
||||
var player = session.State.Player;
|
||||
var overheadVtol = session.State.Contenders[1];
|
||||
var distantGroundRig = session.State.Contenders[2];
|
||||
IsolateContenders(session, player.Id, overheadVtol.Id);
|
||||
|
||||
// Swap player to Anvil (heavy tracked tank, weapons capped at +30 deg pitch)
|
||||
session.SetContenderPose(player.Id, 0f, 0f, 0f);
|
||||
session.State.SpawnChassisDrop(0f, 0f, Catalog.Anvil);
|
||||
Assert.True(session.TrySwapNearbyChassis());
|
||||
Assert.Equal("anvil", player.Grid.Spec.Id);
|
||||
|
||||
// Swap contender 1 to Hornet and position it high overhead (~14m horizontal, ~38m above player => ~+69 deg pitch!)
|
||||
session.SetContenderPose(overheadVtol.Id, 0f, 14f, 0f);
|
||||
session.State.SpawnChassisDrop(0f, 14f, Catalog.Hornet);
|
||||
Assert.True(session.State.TrySwapNearbyChassis(overheadVtol.Id));
|
||||
Assert.Equal("hornet", overheadVtol.Grid.Spec.Id);
|
||||
overheadVtol.AiScavengeCooldown = 999f;
|
||||
overheadVtol.TargetHoverAltAgl = 38f;
|
||||
session.SetContenderPose(overheadVtol.Id, 0f, 14f, 0f);
|
||||
// Step once to seat bodies cleanly
|
||||
session.Step(new PlayerInput(0f, 0f, overheadVtol.X, overheadVtol.Z, false, false, true, AimWorldY: overheadVtol.Y));
|
||||
|
||||
float vtolArmorBefore = overheadVtol.Grid.TotalArmorRatio();
|
||||
|
||||
// 1. Anvil's main cannons (-10..+30 deg) CANNOT fire at +69 deg overhead VTOL
|
||||
for (int t = 0; t < 20; t++)
|
||||
{
|
||||
overheadVtol.TargetHoverAltAgl = 38f;
|
||||
session.SetContenderPose(overheadVtol.Id, 0f, 14f, 0f);
|
||||
session.Step(new PlayerInput(
|
||||
0f, 0f,
|
||||
overheadVtol.X, overheadVtol.Z,
|
||||
Fire: true,
|
||||
InteractPickup: false,
|
||||
Brake: true,
|
||||
AimWorldY: overheadVtol.Y));
|
||||
}
|
||||
Assert.True(player.AllWeaponsOutOfArc,
|
||||
$"Expected Anvil main cannons to report AllWeaponsOutOfArc (in={player.InArcWeaponCount}, out={player.OutOfArcWeaponCount}, pY={player.Y:F1}, vY={overheadVtol.Y:F1}, vSpec={overheadVtol.Grid.Spec.Id}, vAlt={overheadVtol.TargetHoverAltAgl:F1}, vAlive={overheadVtol.Alive}, vPos=({overheadVtol.X:F1},{overheadVtol.Z:F1}))");
|
||||
Assert.All(player.Grid.Mounted.Where(m => m.Spec.Kind == HardpointKind.Weapon), w => Assert.Equal(0f, w.Cooldown));
|
||||
Assert.Equal(vtolArmorBefore, overheadVtol.Grid.TotalArmorRatio());
|
||||
|
||||
// 2. Mount a 1x1 Wide-Arc PointDefenseFlak (-10..+85 deg) onto Anvil's hp.weapon.sponson_r -> CAN hit overhead VTOL!
|
||||
Assert.True(player.Grid.TryMount(Catalog.PointDefenseFlak, "hp.weapon.sponson_r"));
|
||||
int pdTracers = 0;
|
||||
for (int t = 0; t < 25; t++)
|
||||
{
|
||||
overheadVtol.TargetHoverAltAgl = 38f;
|
||||
session.SetContenderPose(overheadVtol.Id, 0f, 14f, 0f);
|
||||
session.Step(new PlayerInput(
|
||||
0f, 0f,
|
||||
overheadVtol.X, overheadVtol.Z,
|
||||
Fire: true,
|
||||
InteractPickup: false,
|
||||
Brake: true,
|
||||
AimWorldY: overheadVtol.Y));
|
||||
pdTracers += session.State.Tracers.Count;
|
||||
}
|
||||
Assert.False(player.AllWeaponsOutOfArc, "Expected Wide-Arc PD module to clear overhead out-of-arc block");
|
||||
Assert.True(pdTracers > 0, "Expected Wide-Arc PD to fire at overhead VTOL");
|
||||
Assert.True(overheadVtol.Grid.TotalArmorRatio() < vtolArmorBefore,
|
||||
"Expected Wide-Arc PD burst to damage overhead VTOL");
|
||||
|
||||
// 3. Second ground rig (Anvil, MaxPitchDeg = 30 deg) placed 140m away (~+15 deg pitch) CAN hit the overhead VTOL!
|
||||
session.SetContenderPose(distantGroundRig.Id, 0f, 154f, MathF.PI);
|
||||
session.State.SpawnChassisDrop(0f, 154f, Catalog.Anvil);
|
||||
Assert.True(session.State.TrySwapNearbyChassis(distantGroundRig.Id));
|
||||
session.SetContenderPose(distantGroundRig.Id, 0f, 154f, MathF.PI);
|
||||
// Unmount player's PD so only distant rig shoots now
|
||||
player.Grid.TryMount(Catalog.Mg762, "hp.weapon.sponson_r");
|
||||
|
||||
float vtolArmorBeforeDistant = overheadVtol.Grid.TotalArmorRatio();
|
||||
for (int t = 0; t < 90; t++)
|
||||
{
|
||||
session.Step(new PlayerInput(0f, 0f, 0f, -20f, false, false, true));
|
||||
}
|
||||
Assert.True(overheadVtol.Grid.TotalArmorRatio() < vtolArmorBeforeDistant,
|
||||
"Expected distant ground rig 140m away (~15 deg pitch) to hit the hovering Hornet inside its 30 deg cannon arc");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GroundRigWithWideArcPd_AutoTracksNearbyAirborneVtolWithoutManualFire()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 42);
|
||||
var player = session.State.Player;
|
||||
var overheadVtol = session.State.Contenders[1];
|
||||
IsolateContenders(session, player.Id, overheadVtol.Id);
|
||||
|
||||
// Swap player to Jackal, mount Wide-Arc PD, leave Fire = false and aim elsewhere!
|
||||
session.SetContenderPose(player.Id, 0f, 0f, 0f);
|
||||
Assert.True(player.Grid.TryMount(Catalog.PointDefenseFlak, "hp.weapon.roof"));
|
||||
|
||||
session.SetContenderPose(overheadVtol.Id, 20f, 25f, 0f);
|
||||
session.State.SpawnChassisDrop(20f, 25f, Catalog.Hornet);
|
||||
Assert.True(session.State.TrySwapNearbyChassis(overheadVtol.Id));
|
||||
Assert.Equal("hornet", overheadVtol.Grid.Spec.Id);
|
||||
overheadVtol.AiScavengeCooldown = 999f;
|
||||
overheadVtol.TargetHoverAltAgl = 28f;
|
||||
session.SetContenderPose(overheadVtol.Id, 20f, 25f, 0f);
|
||||
|
||||
float vtolArmorBefore = overheadVtol.Grid.TotalArmorRatio();
|
||||
bool sawAutoTracer = false;
|
||||
for (int t = 0; t < 45; t++)
|
||||
{
|
||||
overheadVtol.TargetHoverAltAgl = 28f;
|
||||
session.SetContenderPose(overheadVtol.Id, 20f, 25f, 0f);
|
||||
session.Step(new PlayerInput(
|
||||
Throttle: 0f,
|
||||
Steer: 0f,
|
||||
AimWorldX: 0f,
|
||||
AimWorldZ: -50f,
|
||||
Fire: false,
|
||||
InteractPickup: false,
|
||||
Brake: true));
|
||||
if (session.State.Tracers.Count > 0)
|
||||
{
|
||||
sawAutoTracer = true;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.True(sawAutoTracer, "Expected auto-PD to fire tracers at airborne VTOL within 140m even while Fire=false");
|
||||
Assert.True(overheadVtol.Grid.TotalArmorRatio() < vtolArmorBefore,
|
||||
$"Expected auto-PD tracking to hit airborne VTOL (before={vtolArmorBefore:F3}, after={overheadVtol.Grid.TotalArmorRatio():F3}, vY={overheadVtol.Y:F1}, vSpec={overheadVtol.Grid.Spec.Id}, tracers={session.State.Tracers.Count}, lastTracer={(session.State.Tracers.Count > 0 ? $"{session.State.Tracers[^1].EndX:F1},{session.State.Tracers[^1].EndY:F1},{session.State.Tracers[^1].EndZ:F1}" : "none")})");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void QuickBolt_MountsScavengedModuleIntoEmptyMatchingHardpointBeforeCargo()
|
||||
{
|
||||
var state = new MatchState(seed: 42);
|
||||
var player = state.Player;
|
||||
|
||||
// Swap to Anvil (starter Jackal transfers 1 weapon into hp.weapon.sponson_l, leaving hp.weapon.siege_l, hp.weapon.siege_r, hp.weapon.sponson_r empty!)
|
||||
state.SpawnChassisDrop(player.X, player.Z, Catalog.Anvil);
|
||||
Assert.True(state.TrySwapNearbyChassis());
|
||||
Assert.Null(player.Grid.GetMountedOn("hp.weapon.siege_l"));
|
||||
int cargoBefore = player.Grid.Cargo.Count;
|
||||
|
||||
// Drop 1x1 PointDefenseFlak right at player and press [E]
|
||||
state.SpawnModuleDrop(player.X + 0.5f, player.Z, Catalog.PointDefenseFlak);
|
||||
MatchRules.ApplyPlayerInput(state, new PlayerInput(
|
||||
0f, 0f, player.X, player.Z + 10f,
|
||||
Fire: false,
|
||||
InteractPickup: true,
|
||||
Brake: false));
|
||||
|
||||
// Must bolt straight onto empty hp.weapon.siege_l, NOT Cargo!
|
||||
var mountedSiege = player.Grid.GetMountedOn("hp.weapon.siege_l");
|
||||
Assert.NotNull(mountedSiege);
|
||||
Assert.Equal(Catalog.PointDefenseFlak.Id, mountedSiege!.Spec.Id);
|
||||
Assert.Equal(cargoBefore, player.Grid.Cargo.Count);
|
||||
Assert.Equal(BroadcastKind.QuickBolt, state.Broadcast.Latest?.Kind);
|
||||
|
||||
// Now fill remaining weapon slots; next weapon pickup must fall back to Cargo!
|
||||
Assert.True(player.Grid.TryMount(Catalog.Autocannon, "hp.weapon.siege_r"));
|
||||
Assert.True(player.Grid.TryMount(Catalog.Mg762, "hp.weapon.sponson_r"));
|
||||
state.SpawnModuleDrop(player.X + 0.5f, player.Z, Catalog.Flak);
|
||||
MatchRules.ApplyPlayerInput(state, new PlayerInput(
|
||||
0f, 0f, player.X, player.Z + 10f,
|
||||
Fire: false,
|
||||
InteractPickup: true,
|
||||
Brake: false));
|
||||
|
||||
Assert.Equal(cargoBefore + 1, player.Grid.Cargo.Count);
|
||||
Assert.Equal(Catalog.Flak.Id, player.Grid.Cargo[^1].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue