feat: simplified local-space and celestial, removed bubbles
This commit is contained in:
@@ -39,29 +39,20 @@ public sealed partial class SimulationEngine
|
||||
planet.Size,
|
||||
planet.Color,
|
||||
planet.HasRing)).ToList())).ToList(),
|
||||
world.SpatialNodes.Select(ToSpatialNodeDelta).Select(node => new SpatialNodeSnapshot(
|
||||
node.Id,
|
||||
node.SystemId,
|
||||
node.Kind,
|
||||
node.LocalPosition,
|
||||
node.BubbleId,
|
||||
node.ParentNodeId,
|
||||
node.OccupyingStructureId,
|
||||
node.OrbitReferenceId)).ToList(),
|
||||
world.LocalBubbles.Select(ToLocalBubbleDelta).Select(bubble => new LocalBubbleSnapshot(
|
||||
bubble.Id,
|
||||
bubble.NodeId,
|
||||
bubble.SystemId,
|
||||
bubble.Radius,
|
||||
bubble.OccupantShipIds,
|
||||
bubble.OccupantStationIds,
|
||||
bubble.OccupantClaimIds,
|
||||
bubble.OccupantConstructionSiteIds)).ToList(),
|
||||
world.Celestials.Select(ToCelestialDelta).Select(c => new CelestialSnapshot(
|
||||
c.Id,
|
||||
c.SystemId,
|
||||
c.Kind,
|
||||
c.OrbitalAnchor,
|
||||
c.LocalSpaceRadius,
|
||||
c.ParentNodeId,
|
||||
c.OccupyingStructureId,
|
||||
c.OrbitReferenceId)).ToList(),
|
||||
world.Nodes.Select(ToNodeDelta).Select(node => new ResourceNodeSnapshot(
|
||||
node.Id,
|
||||
node.SystemId,
|
||||
node.LocalPosition,
|
||||
node.AnchorNodeId,
|
||||
node.CelestialId,
|
||||
node.SourceKind,
|
||||
node.OreRemaining,
|
||||
node.MaxOre,
|
||||
@@ -72,9 +63,7 @@ public sealed partial class SimulationEngine
|
||||
station.Category,
|
||||
station.SystemId,
|
||||
station.LocalPosition,
|
||||
station.NodeId,
|
||||
station.BubbleId,
|
||||
station.AnchorNodeId,
|
||||
station.CelestialId,
|
||||
station.Color,
|
||||
station.DockedShips,
|
||||
station.DockedShipIds,
|
||||
@@ -95,8 +84,7 @@ public sealed partial class SimulationEngine
|
||||
claim.Id,
|
||||
claim.FactionId,
|
||||
claim.SystemId,
|
||||
claim.NodeId,
|
||||
claim.BubbleId,
|
||||
claim.CelestialId,
|
||||
claim.State,
|
||||
claim.Health,
|
||||
claim.PlacedAtUtc,
|
||||
@@ -105,8 +93,7 @@ public sealed partial class SimulationEngine
|
||||
site.Id,
|
||||
site.FactionId,
|
||||
site.SystemId,
|
||||
site.NodeId,
|
||||
site.BubbleId,
|
||||
site.CelestialId,
|
||||
site.TargetKind,
|
||||
site.TargetDefinitionId,
|
||||
site.BlueprintId,
|
||||
@@ -155,8 +142,7 @@ public sealed partial class SimulationEngine
|
||||
ship.BehaviorPhase,
|
||||
ship.ControllerTaskKind,
|
||||
ship.CommanderObjective,
|
||||
ship.NodeId,
|
||||
ship.BubbleId,
|
||||
ship.CelestialId,
|
||||
ship.DockedStationId,
|
||||
ship.CommanderId,
|
||||
ship.PolicySetId,
|
||||
@@ -191,14 +177,9 @@ public sealed partial class SimulationEngine
|
||||
node.LastDeltaSignature = BuildNodeSignature(node);
|
||||
}
|
||||
|
||||
foreach (var node in world.SpatialNodes)
|
||||
foreach (var celestial in world.Celestials)
|
||||
{
|
||||
node.LastDeltaSignature = BuildSpatialNodeSignature(node);
|
||||
}
|
||||
|
||||
foreach (var bubble in world.LocalBubbles)
|
||||
{
|
||||
bubble.LastDeltaSignature = BuildLocalBubbleSignature(bubble);
|
||||
celestial.LastDeltaSignature = BuildCelestialSignature(celestial);
|
||||
}
|
||||
|
||||
foreach (var station in world.Stations)
|
||||
@@ -255,37 +236,19 @@ public sealed partial class SimulationEngine
|
||||
return deltas;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<SpatialNodeDelta> BuildSpatialNodeDeltas(SimulationWorld world)
|
||||
private static IReadOnlyList<CelestialDelta> BuildCelestialDeltas(SimulationWorld world)
|
||||
{
|
||||
var deltas = new List<SpatialNodeDelta>();
|
||||
foreach (var node in world.SpatialNodes)
|
||||
var deltas = new List<CelestialDelta>();
|
||||
foreach (var celestial in world.Celestials)
|
||||
{
|
||||
var signature = BuildSpatialNodeSignature(node);
|
||||
if (signature == node.LastDeltaSignature)
|
||||
var signature = BuildCelestialSignature(celestial);
|
||||
if (signature == celestial.LastDeltaSignature)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
node.LastDeltaSignature = signature;
|
||||
deltas.Add(ToSpatialNodeDelta(node));
|
||||
}
|
||||
|
||||
return deltas;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<LocalBubbleDelta> BuildLocalBubbleDeltas(SimulationWorld world)
|
||||
{
|
||||
var deltas = new List<LocalBubbleDelta>();
|
||||
foreach (var bubble in world.LocalBubbles)
|
||||
{
|
||||
var signature = BuildLocalBubbleSignature(bubble);
|
||||
if (signature == bubble.LastDeltaSignature)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bubble.LastDeltaSignature = signature;
|
||||
deltas.Add(ToLocalBubbleDelta(bubble));
|
||||
celestial.LastDeltaSignature = signature;
|
||||
deltas.Add(ToCelestialDelta(celestial));
|
||||
}
|
||||
|
||||
return deltas;
|
||||
@@ -424,22 +387,17 @@ public sealed partial class SimulationEngine
|
||||
string.Equals(c.Kind, CommanderKind.Faction, StringComparison.Ordinal));
|
||||
|
||||
private static string BuildNodeSignature(ResourceNodeRuntime node) =>
|
||||
$"{node.SystemId}|{node.Position.X:0.###}|{node.Position.Y:0.###}|{node.Position.Z:0.###}|{node.AnchorNodeId}|{node.OreRemaining:0.###}";
|
||||
$"{node.SystemId}|{node.Position.X:0.###}|{node.Position.Y:0.###}|{node.Position.Z:0.###}|{node.CelestialId}|{node.OreRemaining:0.###}";
|
||||
|
||||
private static string BuildSpatialNodeSignature(NodeRuntime node) =>
|
||||
$"{node.SystemId}|{node.Kind.ToContractValue()}|{node.Position.X:0.###}|{node.Position.Y:0.###}|{node.Position.Z:0.###}|{node.BubbleId}|{node.ParentNodeId}|{node.OccupyingStructureId}|{node.OrbitReferenceId}";
|
||||
|
||||
private static string BuildLocalBubbleSignature(LocalBubbleRuntime bubble) =>
|
||||
$"{bubble.SystemId}|{bubble.NodeId}|{bubble.Radius:0.###}|{string.Join(",", bubble.OccupantShipIds.OrderBy(id => id, StringComparer.Ordinal))}|{string.Join(",", bubble.OccupantStationIds.OrderBy(id => id, StringComparer.Ordinal))}|{string.Join(",", bubble.OccupantClaimIds.OrderBy(id => id, StringComparer.Ordinal))}|{string.Join(",", bubble.OccupantConstructionSiteIds.OrderBy(id => id, StringComparer.Ordinal))}";
|
||||
private static string BuildCelestialSignature(CelestialRuntime celestial) =>
|
||||
$"{celestial.SystemId}|{celestial.Kind.ToContractValue()}|{celestial.Position.X:0.###}|{celestial.Position.Y:0.###}|{celestial.Position.Z:0.###}|{celestial.LocalSpaceRadius:0.###}|{celestial.ParentNodeId}|{celestial.OccupyingStructureId}|{celestial.OrbitReferenceId}";
|
||||
|
||||
private static string BuildStationSignature(SimulationWorld world, StationRuntime station)
|
||||
{
|
||||
var processes = ToStationActionProgressSnapshots(world, station);
|
||||
return string.Join("|",
|
||||
station.SystemId,
|
||||
station.NodeId ?? "none",
|
||||
station.BubbleId ?? "none",
|
||||
station.AnchorNodeId ?? "none",
|
||||
station.CelestialId ?? "none",
|
||||
station.CommanderId ?? "none",
|
||||
station.PolicySetId ?? "none",
|
||||
BuildInventorySignature(station.Inventory),
|
||||
@@ -458,10 +416,10 @@ public sealed partial class SimulationEngine
|
||||
}
|
||||
|
||||
private static string BuildClaimSignature(ClaimRuntime claim) =>
|
||||
$"{claim.FactionId}|{claim.SystemId}|{claim.NodeId}|{claim.BubbleId}|{claim.State}|{claim.Health:0.###}|{claim.ActivatesAtUtc:O}";
|
||||
$"{claim.FactionId}|{claim.SystemId}|{claim.CelestialId}|{claim.State}|{claim.Health:0.###}|{claim.ActivatesAtUtc:O}";
|
||||
|
||||
private static string BuildConstructionSiteSignature(ConstructionSiteRuntime site) =>
|
||||
$"{site.FactionId}|{site.SystemId}|{site.NodeId}|{site.BubbleId}|{site.TargetKind}|{site.TargetDefinitionId}|{site.BlueprintId}|{site.ClaimId}|{site.StationId}|{site.State}|{site.Progress:0.###}|{BuildInventorySignature(site.Inventory)}|{BuildInventorySignature(site.RequiredItems)}|{BuildInventorySignature(site.DeliveredItems)}|{string.Join(",", site.AssignedConstructorShipIds.OrderBy(id => id, StringComparer.Ordinal))}|{string.Join(",", site.MarketOrderIds.OrderBy(id => id, StringComparer.Ordinal))}";
|
||||
$"{site.FactionId}|{site.SystemId}|{site.CelestialId}|{site.TargetKind}|{site.TargetDefinitionId}|{site.BlueprintId}|{site.ClaimId}|{site.StationId}|{site.State}|{site.Progress:0.###}|{BuildInventorySignature(site.Inventory)}|{BuildInventorySignature(site.RequiredItems)}|{BuildInventorySignature(site.DeliveredItems)}|{string.Join(",", site.AssignedConstructorShipIds.OrderBy(id => id, StringComparer.Ordinal))}|{string.Join(",", site.MarketOrderIds.OrderBy(id => id, StringComparer.Ordinal))}";
|
||||
|
||||
private static string BuildMarketOrderSignature(MarketOrderRuntime order) =>
|
||||
$"{order.FactionId}|{order.StationId}|{order.ConstructionSiteId}|{order.Kind}|{order.ItemId}|{order.Amount:0.###}|{order.RemainingAmount:0.###}|{order.Valuation:0.###}|{order.ReserveThreshold?.ToString("0.###") ?? "none"}|{order.PolicySetId}|{order.State}";
|
||||
@@ -486,14 +444,12 @@ public sealed partial class SimulationEngine
|
||||
ship.DefaultBehavior.Kind,
|
||||
ship.DefaultBehavior.Phase ?? "none",
|
||||
ship.ControllerTask.Kind.ToContractValue(),
|
||||
ship.SpatialState.CurrentNodeId ?? "none",
|
||||
ship.SpatialState.CurrentBubbleId ?? "none",
|
||||
ship.SpatialState.CurrentCelestialId ?? "none",
|
||||
ship.DockedStationId ?? "none",
|
||||
ship.CommanderId ?? "none",
|
||||
ship.PolicySetId ?? "none",
|
||||
ship.SpatialState.SpaceLayer,
|
||||
ship.SpatialState.CurrentNodeId ?? "none",
|
||||
ship.SpatialState.CurrentBubbleId ?? "none",
|
||||
ship.SpatialState.CurrentCelestialId ?? "none",
|
||||
ship.SpatialState.MovementRegime,
|
||||
ship.SpatialState.DestinationNodeId ?? "none",
|
||||
ship.SpatialState.Transit?.Regime ?? "none",
|
||||
@@ -528,31 +484,21 @@ public sealed partial class SimulationEngine
|
||||
node.Id,
|
||||
node.SystemId,
|
||||
ToDto(node.Position),
|
||||
node.AnchorNodeId,
|
||||
node.CelestialId,
|
||||
node.SourceKind,
|
||||
node.OreRemaining,
|
||||
node.MaxOre,
|
||||
node.ItemId);
|
||||
|
||||
private static SpatialNodeDelta ToSpatialNodeDelta(NodeRuntime node) => new(
|
||||
node.Id,
|
||||
node.SystemId,
|
||||
node.Kind.ToContractValue(),
|
||||
ToDto(node.Position),
|
||||
node.BubbleId,
|
||||
node.ParentNodeId,
|
||||
node.OccupyingStructureId,
|
||||
node.OrbitReferenceId);
|
||||
|
||||
private static LocalBubbleDelta ToLocalBubbleDelta(LocalBubbleRuntime bubble) => new(
|
||||
bubble.Id,
|
||||
bubble.NodeId,
|
||||
bubble.SystemId,
|
||||
bubble.Radius,
|
||||
bubble.OccupantShipIds.OrderBy(id => id, StringComparer.Ordinal).ToList(),
|
||||
bubble.OccupantStationIds.OrderBy(id => id, StringComparer.Ordinal).ToList(),
|
||||
bubble.OccupantClaimIds.OrderBy(id => id, StringComparer.Ordinal).ToList(),
|
||||
bubble.OccupantConstructionSiteIds.OrderBy(id => id, StringComparer.Ordinal).ToList());
|
||||
private static CelestialDelta ToCelestialDelta(CelestialRuntime celestial) => new(
|
||||
celestial.Id,
|
||||
celestial.SystemId,
|
||||
celestial.Kind.ToContractValue(),
|
||||
ToDto(celestial.Position),
|
||||
celestial.LocalSpaceRadius,
|
||||
celestial.ParentNodeId,
|
||||
celestial.OccupyingStructureId,
|
||||
celestial.OrbitReferenceId);
|
||||
|
||||
private static StationDelta ToStationDelta(SimulationWorld world, StationRuntime station) => new(
|
||||
station.Id,
|
||||
@@ -560,9 +506,7 @@ public sealed partial class SimulationEngine
|
||||
station.Category,
|
||||
station.SystemId,
|
||||
ToDto(station.Position),
|
||||
station.NodeId,
|
||||
station.BubbleId,
|
||||
station.AnchorNodeId,
|
||||
station.CelestialId,
|
||||
station.Color,
|
||||
station.DockedShipIds.Count,
|
||||
station.DockedShipIds.OrderBy(id => id, StringComparer.Ordinal).ToList(),
|
||||
@@ -615,8 +559,7 @@ public sealed partial class SimulationEngine
|
||||
claim.Id,
|
||||
claim.FactionId,
|
||||
claim.SystemId,
|
||||
claim.NodeId,
|
||||
claim.BubbleId,
|
||||
claim.CelestialId,
|
||||
claim.State,
|
||||
claim.Health,
|
||||
claim.PlacedAtUtc,
|
||||
@@ -626,8 +569,7 @@ public sealed partial class SimulationEngine
|
||||
site.Id,
|
||||
site.FactionId,
|
||||
site.SystemId,
|
||||
site.NodeId,
|
||||
site.BubbleId,
|
||||
site.CelestialId,
|
||||
site.TargetKind,
|
||||
site.TargetDefinitionId,
|
||||
site.BlueprintId,
|
||||
@@ -696,8 +638,7 @@ public sealed partial class SimulationEngine
|
||||
ship.DefaultBehavior.Phase,
|
||||
ship.ControllerTask.Kind.ToContractValue(),
|
||||
commander?.ActiveActionName,
|
||||
ship.SpatialState.CurrentNodeId,
|
||||
ship.SpatialState.CurrentBubbleId,
|
||||
ship.SpatialState.CurrentCelestialId,
|
||||
ship.DockedStationId,
|
||||
ship.CommanderId,
|
||||
ship.PolicySetId,
|
||||
@@ -810,8 +751,7 @@ public sealed partial class SimulationEngine
|
||||
private static ShipSpatialStateSnapshot ToShipSpatialStateSnapshot(ShipSpatialStateRuntime state) => new(
|
||||
state.SpaceLayer,
|
||||
state.CurrentSystemId,
|
||||
state.CurrentNodeId,
|
||||
state.CurrentBubbleId,
|
||||
state.CurrentCelestialId,
|
||||
state.LocalPosition is null ? null : ToDto(state.LocalPosition.Value),
|
||||
state.SystemPosition is null ? null : ToDto(state.SystemPosition.Value),
|
||||
state.MovementRegime,
|
||||
|
||||
Reference in New Issue
Block a user