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
|
|
@ -25,9 +25,9 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void MesaBetweenSpectatorAndContender_BlocksLosAndPreventsFiringThroughTerrain()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 42);
|
||||
using var session = new ArenaSession(seed: 42, slot0Human: true);
|
||||
var mesa = FindTallMesa(session.State.Terrain);
|
||||
var player = session.State.Player;
|
||||
var player = session.State.Contenders[0];
|
||||
var spec = session.State.Spectators.Spectators.First(s => s.Tier == SpectatorTier.Patron);
|
||||
|
||||
// Place player and spectator on opposite sides of the tall mesa
|
||||
|
|
@ -42,7 +42,8 @@ namespace RustToDust.Tests
|
|||
|
||||
for (int tick = 0; tick < 10; tick++)
|
||||
{
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.Step();
|
||||
|
||||
Assert.False(session.HasLineOfSight(
|
||||
spec.X, MatchRules.GetObserverEyeY(spec.Y, spec.Grid.Spec.HalfHeight), spec.Z,
|
||||
|
|
@ -59,9 +60,9 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void CrestingRidge_RestoresLosAndAllowsSpectatorEngagement()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 42);
|
||||
using var session = new ArenaSession(seed: 42, slot0Human: true);
|
||||
var mesa = FindTallMesa(session.State.Terrain);
|
||||
var player = session.State.Player;
|
||||
var player = session.State.Contenders[0];
|
||||
var spec = session.State.Spectators.Spectators.First(s => s.Tier == SpectatorTier.Patron);
|
||||
|
||||
// Start occluded across the mesa
|
||||
|
|
@ -69,7 +70,8 @@ namespace RustToDust.Tests
|
|||
session.SetSpectatorPose(spec.Id, mesa.X + mesa.RadiusX + 18f, mesa.Z);
|
||||
session.State.Spectators.OnSpectatorDamaged(spec, player.Id);
|
||||
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.Step();
|
||||
Assert.False(spec.HasTargetLos);
|
||||
|
||||
// Now player crests onto the high mesa plateau overlooking the spectator
|
||||
|
|
@ -79,7 +81,8 @@ namespace RustToDust.Tests
|
|||
bool sawTracer = false;
|
||||
for (int tick = 0; tick < 30; tick++)
|
||||
{
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.Step();
|
||||
if (session.State.Tracers.Count > 0)
|
||||
{
|
||||
sawTracer = true;
|
||||
|
|
@ -95,30 +98,32 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void LowSignatureExemplar_HiddenBehindRidge_IsInvisibleOnRadar_WhileInLosContactIsVisible()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 42);
|
||||
using var session = new ArenaSession(seed: 42, slot0Human: true);
|
||||
var mesa = FindTallMesa(session.State.Terrain);
|
||||
var player = session.State.Player;
|
||||
var player = session.State.Contenders[0];
|
||||
var exemplar = session.State.Spectators.Spectators.First(s => s.Tier == SpectatorTier.Exemplar);
|
||||
var visibleRival = session.State.Contenders[1];
|
||||
|
||||
Assert.True(exemplar.RadarSignature <= 0.25f);
|
||||
|
||||
// Reset memory so exemplar has never been seen yet, then hide it on the far side of the mesa
|
||||
session.State.SpectatorContacts[exemplar.Id] = new PlayerContactMemory();
|
||||
var obs0 = session.State.GetOrCreateObserverState(0);
|
||||
obs0.SpectatorContacts[exemplar.Id] = new PlayerContactMemory();
|
||||
session.SetContenderPose(player.Id, mesa.X - mesa.RadiusX - 18f, mesa.Z);
|
||||
session.SetSpectatorPose(exemplar.Id, mesa.X + mesa.RadiusX + 18f, mesa.Z);
|
||||
|
||||
// Place rival contender nearby in clear open LOS on the player's side of the mesa
|
||||
session.SetContenderPose(visibleRival.Id, mesa.X - mesa.RadiusX - 50f, mesa.Z + 12f);
|
||||
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.Step();
|
||||
|
||||
var exMem = session.State.SpectatorContacts[exemplar.Id];
|
||||
var exMem = obs0.SpectatorContacts[exemplar.Id];
|
||||
Assert.False(exMem.VisibleToPlayer);
|
||||
Assert.False(exMem.FaintHorizonPing);
|
||||
Assert.False(MatchState.IsContactOnRadar(exMem), "Hidden low-signature Exemplar must vanish off player radar");
|
||||
|
||||
var rivalMem = session.State.ContenderContacts[visibleRival.Id];
|
||||
var rivalMem = obs0.ContenderContacts[visibleRival.Id];
|
||||
Assert.True(rivalMem.VisibleToPlayer, "In-LOS contact must be live-visible to player");
|
||||
Assert.True(MatchState.IsContactOnRadar(rivalMem));
|
||||
}
|
||||
|
|
@ -126,9 +131,9 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void StaticCoverWall_BlocksLineOfSight()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 12);
|
||||
using var session = new ArenaSession(seed: 12, slot0Human: true);
|
||||
var box = session.State.ArenaCoverBoxes[0];
|
||||
var player = session.State.Player;
|
||||
var player = session.State.Contenders[0];
|
||||
var rival = session.State.Contenders[1];
|
||||
|
||||
// Ensure rival is a low-profile ground vehicle shorter than the 4m ruin cover wall
|
||||
|
|
@ -208,7 +213,7 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void OccludedSpectators_DoNotLeakLiveTargetAfterMemoryExpires_FiveSeconds()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 42);
|
||||
using var session = new ArenaSession(seed: 42, slot0Human: true);
|
||||
// Shrink safe circle so the tall mesa perimeter is outside SafeRadius
|
||||
session.State.Time = 360f;
|
||||
session.State.Spectators.UpdateSafeRadius(session.State.Time);
|
||||
|
|
@ -230,7 +235,7 @@ namespace RustToDust.Tests
|
|||
}
|
||||
Assert.True(bestMinRadius > 0f, "Expected at least one tall Mesa in generated terrain.");
|
||||
|
||||
var player = session.State.Player;
|
||||
var player = session.State.Contenders[0];
|
||||
var tourists = session.State.Spectators.Spectators.Where(s => s.Tier == SpectatorTier.Tourist).ToList();
|
||||
var provokedSpec = tourists[0];
|
||||
var clearedSpec = tourists[1];
|
||||
|
|
@ -265,7 +270,8 @@ namespace RustToDust.Tests
|
|||
session.SetContenderPose(player.Id, specSideX - (negIsFurther ? 12f : -12f), mesa.Z);
|
||||
session.SetSpectatorPose(provokedSpec.Id, specSideX, mesa.Z);
|
||||
session.State.Spectators.OnSpectatorDamaged(provokedSpec, player.Id);
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.Step();
|
||||
Assert.True(provokedSpec.HasTargetLos, "Expected initial LOS before player drops behind cover");
|
||||
|
||||
float provokedKnownX = provokedSpec.LastKnownTargetX;
|
||||
|
|
@ -277,7 +283,8 @@ namespace RustToDust.Tests
|
|||
session.SetSpectatorPose(clearedSpec.Id, specSideX, mesa.Z + 4f);
|
||||
|
||||
// Verify clearedSpec gets Pass-2 Cleared assignment without LOS
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.Step();
|
||||
Assert.False(provokedSpec.HasTargetLos);
|
||||
Assert.Equal(SpectatorStance.Cleared, clearedSpec.Stance);
|
||||
Assert.False(clearedSpec.HasTargetLos);
|
||||
|
|
@ -294,7 +301,8 @@ namespace RustToDust.Tests
|
|||
session.SetContenderPose(player.Id, occludedX, latZ);
|
||||
}
|
||||
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.Step();
|
||||
|
||||
Assert.False(provokedSpec.HasTargetLos, $"Provoked spectator regained unexpected LOS at tick {tick}");
|
||||
Assert.False(clearedSpec.HasTargetLos, $"Cleared spectator regained unexpected LOS at tick {tick}");
|
||||
|
|
@ -427,9 +435,9 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void AiContender_ImmediatelyDropsTrackingAndFiring_OnExactTickLosBreaks()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 12);
|
||||
using var session = new ArenaSession(seed: 12, slot0Human: true);
|
||||
var box = session.State.ArenaCoverBoxes[0];
|
||||
var player = session.State.Player;
|
||||
var player = session.State.Contenders[0];
|
||||
var ai = session.State.Contenders[1];
|
||||
|
||||
// Move other rivals far away so only ai <-> player interaction is isolated
|
||||
|
|
@ -467,7 +475,8 @@ namespace RustToDust.Tests
|
|||
// Advance `phase` ticks in open LOS; open-LOS acquisition must be immediate on tick 0!
|
||||
for (int t = 0; t <= phase; t++)
|
||||
{
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.Step();
|
||||
Assert.Equal(player.Id, ai.AiTargetContenderId);
|
||||
Assert.True(ai.FireCmd, $"Expected AI to acquire open-LOS target and fire immediately (phase={phase}, t={t})");
|
||||
}
|
||||
|
|
@ -484,7 +493,8 @@ namespace RustToDust.Tests
|
|||
// Move laterally behind cover to verify AI never steers/aims toward hidden coords
|
||||
session.SetContenderPose(player.Id, box.X + (occTick % 2 == 0 ? 1.5f : -1.5f), box.Z + box.HalfZ + 8f, yaw: 0f);
|
||||
}
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.Step();
|
||||
|
||||
Assert.Null(ai.AiTargetContenderId);
|
||||
Assert.False(ai.FireCmd, $"AI leaked FireCmd on occluded tick {occTick} (phase={phase})");
|
||||
|
|
@ -497,9 +507,9 @@ namespace RustToDust.Tests
|
|||
[Fact]
|
||||
public void PlayerDetectedByCount_StaysExactZero_UnderAsymmetricCover_NoFlicker()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 12);
|
||||
using var session = new ArenaSession(seed: 12, slot0Human: true);
|
||||
var box = session.State.ArenaCoverBoxes.First(b => b.HalfY >= 2.8f);
|
||||
var player = session.State.Player;
|
||||
var player = session.State.Contenders[0];
|
||||
var rival = session.State.Contenders[1];
|
||||
|
||||
// Move all other rivals and spectators far away (> 500m) so only rival <-> player is tested
|
||||
|
|
@ -536,10 +546,12 @@ namespace RustToDust.Tests
|
|||
// Re-pin poses each tick so drift never alters cover geometry
|
||||
session.SetContenderPose(player.Id, box.X, box.Z - box.HalfZ - 4f);
|
||||
session.SetContenderPose(rival.Id, box.X, box.Z + box.HalfZ + 40f);
|
||||
session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
|
||||
session.Step();
|
||||
|
||||
Assert.True(session.State.ContenderContacts[rival.Id].VisibleToPlayer);
|
||||
Assert.Equal(0, session.State.PlayerDetectedByCount);
|
||||
var obs0 = session.State.GetOrCreateObserverState(0);
|
||||
Assert.True(obs0.ContenderContacts[rival.Id].VisibleToPlayer);
|
||||
Assert.Equal(0, obs0.DetectedByCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue