Cut 5c-1: Multi-human authoritative sim, SimSnapshot/SimEvent boundary, RustToDust.Net & RustToDust.Server
This commit is contained in:
parent
8eba2ea39f
commit
d8f5c49b8d
34 changed files with 5785 additions and 700 deletions
|
|
@ -11,8 +11,8 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void DrivingAndFiring_MovesBuggyInYmirAndBuildsWeaponHeat()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 42);
|
||||
var player = session.State.Player;
|
||||
using var session = new ArenaSession(seed: 42, slot0Human: true);
|
||||
var player = session.State.Contenders[0];
|
||||
float startX = player.X;
|
||||
float startZ = player.Z;
|
||||
float startYaw = player.Yaw;
|
||||
|
|
@ -20,7 +20,7 @@ namespace RustToDust.Tests
|
|||
|
||||
for (int tick = 0; tick < 120; tick++)
|
||||
{
|
||||
session.Step(new PlayerInput(
|
||||
session.SetHumanInput(0, new PlayerInput(
|
||||
Throttle: 1f,
|
||||
Steer: 0.45f,
|
||||
AimWorldX: player.X + 40f,
|
||||
|
|
@ -28,6 +28,7 @@ namespace RustToDust.Tests
|
|||
Fire: true,
|
||||
InteractPickup: false,
|
||||
Brake: false));
|
||||
session.Step();
|
||||
|
||||
if (session.State.Tracers.Count > 0)
|
||||
{
|
||||
|
|
@ -52,30 +53,30 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void ChassisSwap_ToManticoreAndRaptor_ReplacesBodyWithoutLeakingYmirLanes()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 77);
|
||||
var player = session.State.Player;
|
||||
using var session = new ArenaSession(seed: 77, slot0Human: true);
|
||||
var player = session.State.Contenders[0];
|
||||
int initialFreeSlots = session.World.FreeBodySlots;
|
||||
|
||||
// Step once to settle world
|
||||
session.Step(new PlayerInput(0f, 0f, 0f, 0f, false, false, false));
|
||||
session.Step();
|
||||
|
||||
// Spawn Manticore (Dorsal) right beside player and swap
|
||||
session.State.SpawnChassisDrop(player.X + 1f, player.Z + 1f, Catalog.Manticore);
|
||||
Assert.True(session.TrySwapNearbyChassis());
|
||||
Assert.True(session.TrySwapNearbyChassis(0));
|
||||
Assert.Equal("manticore", player.Grid.Spec.Id);
|
||||
Assert.Equal(GridPlane.Dorsal, player.Grid.Spec.Plane);
|
||||
|
||||
// Step so Ymir reclaims old tombstone lane
|
||||
session.Step(new PlayerInput(0f, 0f, 0f, 0f, false, false, false));
|
||||
session.Step();
|
||||
Assert.Equal(initialFreeSlots, session.World.FreeBodySlots);
|
||||
|
||||
// Now spawn Raptor (Coronal) beside player and swap
|
||||
session.State.SpawnChassisDrop(player.X + 1f, player.Z + 1f, Catalog.Raptor);
|
||||
Assert.True(session.TrySwapNearbyChassis());
|
||||
Assert.True(session.TrySwapNearbyChassis(0));
|
||||
Assert.Equal("raptor", player.Grid.Spec.Id);
|
||||
Assert.Equal(GridPlane.Coronal, player.Grid.Spec.Plane);
|
||||
|
||||
session.Step(new PlayerInput(0f, 0f, 0f, 0f, false, false, false));
|
||||
session.Step();
|
||||
Assert.Equal(initialFreeSlots, session.World.FreeBodySlots);
|
||||
}
|
||||
|
||||
|
|
@ -101,20 +102,21 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void BroadsideFire_UsesDirectionalSupportRadiusNotMaxExtent()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 19);
|
||||
var player = session.State.Player;
|
||||
using var session = new ArenaSession(seed: 19, slot0Human: true);
|
||||
var player = session.State.Contenders[0];
|
||||
|
||||
// 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.True(session.TrySwapNearbyChassis(0));
|
||||
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));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, false));
|
||||
session.Step();
|
||||
float broadsideX = MathF.Cos(player.Yaw);
|
||||
float broadsideZ = -MathF.Sin(player.Yaw);
|
||||
|
||||
session.Step(new PlayerInput(
|
||||
session.SetHumanInput(0, new PlayerInput(
|
||||
Throttle: 0f,
|
||||
Steer: 0f,
|
||||
AimWorldX: player.X + broadsideX * 30f,
|
||||
|
|
@ -122,6 +124,7 @@ namespace RustToDust.Tests
|
|||
Fire: true,
|
||||
InteractPickup: false,
|
||||
Brake: true));
|
||||
session.Step();
|
||||
|
||||
Assert.NotEmpty(session.State.Tracers);
|
||||
var tracer = session.State.Tracers[^1];
|
||||
|
|
@ -136,15 +139,16 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void TracerEvent_AssignsMonotonicId_AndPreservesAcrossAdvance()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 19);
|
||||
var player = session.State.Player;
|
||||
using var session = new ArenaSession(seed: 19, slot0Human: true);
|
||||
var player = session.State.Contenders[0];
|
||||
float aimX = player.X + MathF.Sin(player.Yaw) * 25f;
|
||||
float aimZ = player.Z + MathF.Cos(player.Yaw) * 25f;
|
||||
|
||||
var ids = new List<int>();
|
||||
for (int tick = 0; tick < 30 && ids.Count < 2; tick++)
|
||||
{
|
||||
session.Step(new PlayerInput(0f, 0f, aimX, aimZ, Fire: true, InteractPickup: false, Brake: true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, aimX, aimZ, Fire: true, InteractPickup: false, Brake: true));
|
||||
session.Step();
|
||||
foreach (var t in session.State.Tracers)
|
||||
{
|
||||
if (!ids.Contains(t.Id))
|
||||
|
|
|
|||
Loading…
Reference in a new issue