Tests: the two flight tests fit their ships by name; a consumable-hosted Listener test
ReachIsWhatTheShipCanDo and TheThrustersReadLiveThrust built their ships with the generator, whose draw follows the run's item stream and so the catalog's census; the applied sensor catalog shifted it. They now fit the Djinni (a Talaria on each thruster hardpoint, reactor, cockpit) and the Longinus (EvLonginus) by name. AConsumableListenerHearsAtItsMultiple pins Entity.HearingMultiple over an active consumable's Listener. Not yet verified. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ad7613eb83
commit
b753dbe337
3 changed files with 59 additions and 2 deletions
|
|
@ -60,6 +60,7 @@ public sealed partial class ContactRevealTests : IDisposable
|
|||
cache.Upsert(Eye("Shout", sensitivity: 2f, interceptFactor: 2f, beamWidth: 10f));
|
||||
cache.Upsert(Eye("Roar", sensitivity: 2f, interceptFactor: .5f, beamWidth: 10f));
|
||||
cache.Upsert(Listener("Listener", 3f));
|
||||
cache.Upsert(new ConsumableItemData { Name = "Earpiece", Duration = 30f, Shape = new Shape(), Behaviors = { new ListenerData { Multiple = Const(3f) } } });
|
||||
cache.Upsert(Tool("Reactor", new ReactorData { Charge = Const(1000), Efficiency = Const(1), OverloadEfficiency = Const(1), ThrottlingFactor = Const(2) }));
|
||||
cache.Upsert(Tool("Targeting", new TargetingSystemData { Accuracy = Const(1), Resolution = Const(1000f), Precision = Const(1000f), Tracking = Const(1000000f) }));
|
||||
cache.Upsert(Tool("Thruster", new ThrusterData { Thrust = Const(100), Visibility = Const(10), Heat = Const(0), EnergyUsage = Const(10) }));
|
||||
|
|
|
|||
|
|
@ -52,6 +52,38 @@ public sealed partial class RunStartTests
|
|||
return (arena, longinus, djinni);
|
||||
}
|
||||
|
||||
// The Djinni fitted by name: a Talaria on each of its thruster hardpoints (the hull's own positions and rotations), the
|
||||
// reactor and the cockpit. What the thrusters push with is then the gear the test names, not what the generator drew.
|
||||
private ScenarioFit EvDjinni(ScenarioStage stage)
|
||||
{
|
||||
var hull = _cache.GetByName<HullData>("Djinni");
|
||||
var slots = hull.Hardpoints.Where(h => h.Type == HardpointType.Thruster).Select(h => ("Talaria", h.Position, h.Rotation)).ToList();
|
||||
var reactor = hull.Hardpoints.First(h => h.Type == HardpointType.Reactor);
|
||||
var cockpit = hull.Hardpoints.First(h => h.Type == HardpointType.ControlModule);
|
||||
slots.Add(("Core Power", reactor.Position, reactor.Rotation));
|
||||
slots.Add(("Cockpit 2x2", cockpit.Position, cockpit.Rotation));
|
||||
return stage.Fit("Djinni", slots.ToArray());
|
||||
}
|
||||
|
||||
// The two ships the flight tests measure, fitted by name and far apart in the fixture arena: the Djinni's eight Talaria
|
||||
// and the Longinus's two Large Drives and two Talaria (EvLonginus). Neither follows the catalog's census: the generator
|
||||
// draws from the run's item stream, so a catalog cut would change which gear a generated hull carried (sensor-catalog h1).
|
||||
private (Zone arena, Ship longinus, Ship djinni) EvFitted()
|
||||
{
|
||||
Ship longinus = null, djinni = null;
|
||||
var scenario = new Scripted(false, stage =>
|
||||
{
|
||||
stage.Player(stage.Bare("Djinni"), float2(-50000, -50000));
|
||||
djinni = stage.Place(EvDjinni(stage), float2(-10000, -30000), facing: float2(0, 1)) as Ship;
|
||||
longinus = stage.Place(EvLonginus(stage), float2(-30000, -30000), facing: float2(0, 1)) as Ship;
|
||||
});
|
||||
var (_, arena, _, failures) = Launch(scenario, Inputs(() => GalaxySeed));
|
||||
Assert.True(failures.Count == 0, string.Join("; ", failures));
|
||||
Assert.NotNull(longinus);
|
||||
Assert.NotNull(djinni);
|
||||
return (arena, longinus, djinni);
|
||||
}
|
||||
|
||||
// Idle long enough for stats and power to reach their idle state, then at rest, facing +y,
|
||||
// and, after three seconds of coasting, with nothing observed: the track forgets on its own.
|
||||
private static void EvSettle(Ship ship)
|
||||
|
|
@ -272,7 +304,7 @@ public sealed partial class RunStartTests
|
|||
[Fact]
|
||||
public void ReachIsWhatTheShipCanDo()
|
||||
{
|
||||
var (_, longinus, djinni) = EvFleet();
|
||||
var (_, longinus, djinni) = EvFitted();
|
||||
const float window = .5f;
|
||||
var results = new List<(string name, (float noseOn, float broadside) reach, (float noseOn, float broadside) allocated, (float noseOn, float broadside) measured)>();
|
||||
foreach (var (name, ship) in new[] { ("longinus", longinus), ("djinni", djinni) })
|
||||
|
|
@ -787,7 +819,7 @@ public sealed partial class RunStartTests
|
|||
[Fact]
|
||||
public void TheThrustersReadLiveThrust()
|
||||
{
|
||||
var (_, _, djinni) = EvFleet();
|
||||
var (_, _, djinni) = EvFitted();
|
||||
EvSettle(djinni);
|
||||
djinni.Update(EvDt);
|
||||
var thrusters = djinni.GetBehaviors<Thruster>().ToList();
|
||||
|
|
|
|||
|
|
@ -77,6 +77,30 @@ public sealed partial class ContactRevealTests
|
|||
Assert.Empty(ear.RevealsOf(p));
|
||||
}
|
||||
|
||||
// ---- AConsumableListenerHearsAtItsMultiple ----
|
||||
|
||||
// The Earpiece is a consumable hosting a Listener (Multiple 3): an observer with it active hears the "Eye" at 900, the
|
||||
// same as with the gear; with it not yet activated it has no instrument at all.
|
||||
[Theory]
|
||||
[InlineData(true, 899f, true)]
|
||||
[InlineData(true, 901f, false)]
|
||||
[InlineData(false, 100f, false)]
|
||||
public void AConsumableListenerHearsAtItsMultiple(bool activated, float distance, bool heard)
|
||||
{
|
||||
var p = Add(float3(0, 0, 0), new[] { "Eye" });
|
||||
var ear = Add(float3(distance, 0, 0));
|
||||
if (activated)
|
||||
{
|
||||
var data = _openCache.GetByName<ConsumableItemData>("Earpiece");
|
||||
ear.ActivateConsumable(Assert.IsType<ConsumableItem>(_items.CreateInstance(_items.CreateLot(data, _maker, .5f))));
|
||||
Assert.Single(ear.FindActiveConsumable(data).Behaviors.OfType<Listener>()); // fixture: the consumable hosts it
|
||||
}
|
||||
|
||||
PingAt(p);
|
||||
|
||||
Assert.Equal(heard ? 1 : 0, ear.RevealsOf(p).Count());
|
||||
}
|
||||
|
||||
// ---- ListenerDataRoundTripsAsUnionKey50 ----
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Reference in a new issue