Tests: drive agents through the seam (apply after a direct agent update; the duel's scripted player commands)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9a2a9390e1
commit
26a25fce3a
4 changed files with 16 additions and 6 deletions
|
|
@ -587,7 +587,11 @@ public sealed class ConsumableAiTests : IDisposable
|
|||
s.Zone.Update(.05f);
|
||||
Assert.True(s.Agent.Target.Value.IsNone);
|
||||
agent.Task = new FollowTask { Anchor = s.Prey, Standoff = 100 };
|
||||
for (var i = 0; i < 6 && !(s.State is FollowState); i++) agent.Update(.05f);
|
||||
for (var i = 0; i < 6 && !(s.State is FollowState); i++)
|
||||
{
|
||||
agent.Update(.05f);
|
||||
PilotApplier.Apply(s.Agent);
|
||||
}
|
||||
Assert.True(s.State is FollowState, $"the agent is in {s.State?.GetType().Name}");
|
||||
|
||||
void Paint(float strength)
|
||||
|
|
@ -595,6 +599,7 @@ public sealed class ConsumableAiTests : IDisposable
|
|||
s.Agent.ReceivePaint(s.Locker, s.Locker.Equipment.Single(i => i.Behaviors.Any(b => b is LockWeapon)), PaintMode.Track, strength);
|
||||
s.Agent.PublishInbox();
|
||||
agent.Update(.05f);
|
||||
PilotApplier.Apply(s.Agent);
|
||||
}
|
||||
Paint(.3f);
|
||||
Assert.False(s.Active(s.Vent));
|
||||
|
|
|
|||
|
|
@ -371,6 +371,7 @@ public sealed class FireControlPerWeaponTests : IDisposable
|
|||
flight.Join(agent, new PatrolOrbitsTask());
|
||||
|
||||
flight.Update(.1f);
|
||||
PilotApplier.Apply(r.Shooter);
|
||||
|
||||
Assert.Equal(expected, ((FollowTask) agent.Task).Standoff, 2);
|
||||
}
|
||||
|
|
@ -730,7 +731,9 @@ public sealed class FireControlPerWeaponTests : IDisposable
|
|||
// update leaves the root state for combat, the second is combat deciding.
|
||||
var agent = new Minion(r.Shooter, FactionDoctrine.Default(r.Shooter.ItemManager.GameplaySettings).Combatant);
|
||||
agent.Update(.01f);
|
||||
PilotApplier.Apply(r.Shooter);
|
||||
agent.Update(.01f);
|
||||
PilotApplier.Apply(r.Shooter);
|
||||
|
||||
Assert.True(r.Gun.Weapon.Firing);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ public sealed class FlightTests : IDisposable
|
|||
private void Tick(float dt)
|
||||
{
|
||||
foreach (var flight in _zone.Flights.ToArray()) flight.Update(dt);
|
||||
// The flight-only step: each member's command (its flight's designation) is applied as the zone step applies it.
|
||||
foreach (var entity in _zone.Entities.ToArray()) PilotApplier.Apply(entity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -140,8 +140,8 @@ public sealed partial class RunStartTests
|
|||
var launched = Launch(new Duel());
|
||||
Assert.Empty(launched.failures);
|
||||
_items.Random = new CultMath.Random(0xC0FFEE);
|
||||
launched.staged.Player.MovementDirection = float2(0, 1);
|
||||
launched.staged.Player.Turn = .5f;
|
||||
launched.staged.Player.Command.Movement = float2(0, 1);
|
||||
launched.staged.Player.Command.Turn = TurnCommand.OfRate(.5f);
|
||||
foreach (var ship in launched.arena.Entities.OfType<Ship>())
|
||||
ship.SetTarget(launched.arena.Entities.OfType<Ship>().First(other => other != ship));
|
||||
return (launched.arena, launched.staged.Player);
|
||||
|
|
@ -238,8 +238,8 @@ public sealed partial class RunStartTests
|
|||
Assert.True(turned > 60, "the held turn turned the ship");
|
||||
|
||||
// A write to Direction between steps (staging, a load, a wormhole exit) is not a turn.
|
||||
player.Turn = 0;
|
||||
player.MovementDirection = float2(0, 0); // the drives are idled so the Direction write below is tested alone
|
||||
player.Command.Turn = TurnCommand.OfRate(0);
|
||||
player.Command.Movement = float2(0, 0); // the drives are idled so the Direction write below is tested alone
|
||||
for (var step = 0; step < 600 && abs(player.TurnRate) > 0; step++) arena.Update(ClockFrame);
|
||||
player.Direction = normalize(float2(3, -4));
|
||||
arena.Update(ClockFrame);
|
||||
|
|
@ -295,7 +295,7 @@ public sealed partial class RunStartTests
|
|||
public void DrawnRotationFollowsTheTurn()
|
||||
{
|
||||
var (arena, player) = LaunchDuel();
|
||||
player.Turn = 1f;
|
||||
player.Command.Turn = TurnCommand.OfRate(1f);
|
||||
for (var step = 0; step < 300; step++) arena.Update(ClockFrame);
|
||||
var rate = player.TurnRate;
|
||||
Assert.True(abs(rate) > .05f, "the ship is turning");
|
||||
|
|
|
|||
Loading…
Reference in a new issue