Add world delta streaming and viewer smoothing

This commit is contained in:
2026-03-12 19:03:13 -04:00
parent 2fb90162ef
commit 9849dbae61
10 changed files with 966 additions and 177 deletions

View File

@@ -3,6 +3,8 @@ namespace SpaceGame.Simulation.Api.Contracts;
public sealed record WorldSnapshot(
string Label,
int Seed,
long Sequence,
int TickIntervalMs,
DateTimeOffset GeneratedAtUtc,
IReadOnlyList<SystemSnapshot> Systems,
IReadOnlyList<ResourceNodeSnapshot> Nodes,
@@ -10,6 +12,24 @@ public sealed record WorldSnapshot(
IReadOnlyList<ShipSnapshot> Ships,
IReadOnlyList<FactionSnapshot> Factions);
public sealed record WorldDelta(
long Sequence,
int TickIntervalMs,
DateTimeOffset GeneratedAtUtc,
bool RequiresSnapshotRefresh,
IReadOnlyList<SimulationEventRecord> Events,
IReadOnlyList<ResourceNodeDelta> Nodes,
IReadOnlyList<StationDelta> Stations,
IReadOnlyList<ShipDelta> Ships,
IReadOnlyList<FactionDelta> Factions);
public sealed record SimulationEventRecord(
string EntityKind,
string EntityId,
string Kind,
string Message,
DateTimeOffset OccurredAtUtc);
public sealed record SystemSnapshot(
string Id,
string Label,
@@ -33,6 +53,14 @@ public sealed record ResourceNodeSnapshot(
float MaxOre,
string ItemId);
public sealed record ResourceNodeDelta(
string Id,
string SystemId,
Vector3Dto Position,
float OreRemaining,
float MaxOre,
string ItemId);
public sealed record StationSnapshot(
string Id,
string Label,
@@ -45,6 +73,18 @@ public sealed record StationSnapshot(
float RefinedStock,
string FactionId);
public sealed record StationDelta(
string Id,
string Label,
string Category,
string SystemId,
Vector3Dto Position,
string Color,
int DockedShips,
float OreStored,
float RefinedStock,
string FactionId);
public sealed record ShipSnapshot(
string Id,
string Label,
@@ -52,6 +92,28 @@ public sealed record ShipSnapshot(
string ShipClass,
string SystemId,
Vector3Dto Position,
Vector3Dto Velocity,
Vector3Dto TargetPosition,
string State,
string? OrderKind,
string DefaultBehaviorKind,
string ControllerTaskKind,
float Cargo,
float CargoCapacity,
string? CargoItemId,
string FactionId,
float Health,
IReadOnlyList<string> History);
public sealed record ShipDelta(
string Id,
string Label,
string Role,
string ShipClass,
string SystemId,
Vector3Dto Position,
Vector3Dto Velocity,
Vector3Dto TargetPosition,
string State,
string? OrderKind,
string DefaultBehaviorKind,
@@ -73,4 +135,14 @@ public sealed record FactionSnapshot(
int ShipsBuilt,
int ShipsLost);
public sealed record FactionDelta(
string Id,
string Label,
string Color,
float Credits,
float OreMined,
float GoodsProduced,
int ShipsBuilt,
int ShipsLost);
public sealed record Vector3Dto(float X, float Y, float Z);