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:
@@ -11,8 +11,6 @@ namespace TheLivingWorld.Api.Simulation;
|
||||
/// </summary>
|
||||
public sealed class WorldSimulation : IDisposable
|
||||
{
|
||||
private static readonly ClockSystem ClockSystem = new();
|
||||
|
||||
private readonly object _gate = new();
|
||||
private readonly World _ecs;
|
||||
private readonly Entity _clockEntity;
|
||||
@@ -85,10 +83,11 @@ public sealed class WorldSimulation : IDisposable
|
||||
|
||||
if (realElapsed > TimeSpan.Zero)
|
||||
{
|
||||
var before = SnapshotClockUnlocked();
|
||||
// Compare raw ticks: this runs at 10 Hz per world, so snapshotting DTOs just to diff would
|
||||
// allocate for nothing.
|
||||
var before = _ecs.Get<GameClock>(_clockEntity).Ticks;
|
||||
ClockSystem.Execute(_ecs, realElapsed);
|
||||
var after = SnapshotClockUnlocked();
|
||||
if (after.GameTime != before.GameTime) _dirty = true;
|
||||
if (_ecs.Get<GameClock>(_clockEntity).Ticks != before) _dirty = true;
|
||||
}
|
||||
|
||||
_lastTickedAt = DateTimeOffset.UtcNow;
|
||||
|
||||
Reference in New Issue
Block a user