Enhance world simulation and API functionality; implement clock management improvements, ensure proper handling of world states during updates, and refine data persistence methods to prevent resurrecting deleted worlds.

This commit is contained in:
Leonid Pershin
2026-08-16 22:02:45 +03:00
parent 9d1e3c29c7
commit 3610ee8051
12 changed files with 352 additions and 80 deletions
@@ -80,6 +80,25 @@ public sealed class WorldSimulationTests
GameTime.DefaultStart.AddMinutes(17));
}
[Fact]
public void Catch_up_skips_a_world_that_was_paused_when_the_host_went_down()
{
var summary = ReadySummary() with
{
Clock = WorldSimulation.DefaultClock() with { Paused = true },
LastTickedAt = DateTimeOffset.UtcNow - TimeSpan.FromHours(6),
};
using var simulation = WorldSimulation.Create(summary, catchUp: true);
Assert.Equal(GameTime.DefaultStart, simulation.SnapshotClock().GameTime);
// Unpausing must not replay the six hours spent paused offline either.
var resumed = simulation.Update(new UpdateClockRequest { Paused = false });
Assert.False(resumed.Paused);
Assert.InRange(resumed.GameTime, GameTime.DefaultStart, GameTime.DefaultStart.AddMinutes(5));
}
[Fact]
public void OverlayForApi_strips_last_ticked_at()
{