Use typed orbit and body keys in run commits

This commit is contained in:
Meta Vens 2026-06-15 16:27:23 +01:00
commit ec124bb9d4
6 changed files with 49 additions and 16 deletions

Binary file not shown.

View file

@ -271,8 +271,8 @@ try
{
new AetheriaRuntimeOrbitSnapshotCommit
{
OrbitLegacyId = "smoke:orbit",
ParentLegacyId = "smoke:parent-orbit",
OrbitKey = "aetheria.orbit:legacy:smoke:orbit",
ParentOrbitKey = "aetheria.orbit:legacy:smoke:parent-orbit",
Distance = 100.0,
Phase = 0.25,
FixedPositionX = 5.0,
@ -283,10 +283,10 @@ try
{
new AetheriaRuntimeBodySnapshotCommit
{
BodyLegacyId = "smoke:body",
BodyKey = "aetheria.body:legacy:smoke:body",
Kind = "asteroid_belt",
Name = "Smoke Belt",
OrbitLegacyId = "smoke:orbit",
OrbitKey = "aetheria.orbit:legacy:smoke:orbit",
Mass = 42.0,
Resources = new[]
{
@ -702,9 +702,12 @@ try
run.FactionRelationships[0].Standing == 3 &&
zone?.EntityKeys.Length == 1 &&
zone.Orbits.Length == 1 &&
zone.Orbits[0].OrbitId == "smoke:orbit" &&
zone.Orbits[0].OrbitId == "aetheria.orbit:legacy:smoke:orbit" &&
zone.Orbits[0].ParentId == "aetheria.orbit:legacy:smoke:parent-orbit" &&
zone.Orbits[0].FixedPosition.X == 5.0 &&
zone.Bodies.Length == 1 &&
zone.Bodies[0].BodyId == "aetheria.body:legacy:smoke:body" &&
zone.Bodies[0].OrbitId == "aetheria.orbit:legacy:smoke:orbit" &&
zone.Bodies[0].Kind == "asteroid_belt" &&
zone.Bodies[0].Resources.Length == 1 &&
zone.Bodies[0].Resources[0].ItemKey == "aetheria.item_definition:legacy:smoke:ore" &&
@ -849,8 +852,12 @@ try
packageZones[0].Name != "Unity Smoke Zone" ||
packageZones[0].EntityKeys.Count != 1 ||
packageZones[0].Orbits.Count != 1 ||
packageZones[0].Orbits[0].OrbitId != "aetheria.orbit:legacy:smoke:orbit" ||
packageZones[0].Orbits[0].ParentId != "aetheria.orbit:legacy:smoke:parent-orbit" ||
packageZones[0].Orbits[0].FixedPositionX != 5.0 ||
packageZones[0].Bodies.Count != 1 ||
packageZones[0].Bodies[0].BodyId != "aetheria.body:legacy:smoke:body" ||
packageZones[0].Bodies[0].OrbitId != "aetheria.orbit:legacy:smoke:orbit" ||
packageZones[0].Bodies[0].ResourceCount != 1 ||
packageZones[0].Bodies[0].AsteroidCount != 1 ||
packageZones[0].Bodies[0].DamagedAsteroidCount != 1 ||

View file

@ -288,8 +288,8 @@ public static class AetheriaRuntimeCommitLogApplier
return (orbits ?? Array.Empty<AetheriaRuntimeOrbitSnapshotCommit>())
.Select(orbit => new AetheriaOrbitSnapshot
{
OrbitId = orbit.OrbitLegacyId ?? "",
ParentId = orbit.ParentLegacyId ?? "",
OrbitId = ReferenceKey(orbit.OrbitKey ?? "", "aetheria.orbit", orbit.OrbitLegacyId ?? ""),
ParentId = ReferenceKey(orbit.ParentOrbitKey ?? "", "aetheria.orbit", orbit.ParentLegacyId ?? ""),
Distance = orbit.Distance,
Phase = orbit.Phase,
FixedPosition = new AetheriaVector2
@ -309,10 +309,10 @@ public static class AetheriaRuntimeCommitLogApplier
return (bodies ?? Array.Empty<AetheriaRuntimeBodySnapshotCommit>())
.Select(body => new AetheriaBodySnapshot
{
BodyId = body.BodyLegacyId ?? "",
BodyId = ReferenceKey(body.BodyKey ?? "", "aetheria.body", body.BodyLegacyId ?? ""),
Kind = body.Kind ?? "",
Name = body.Name ?? "",
OrbitId = body.OrbitLegacyId ?? "",
OrbitId = ReferenceKey(body.OrbitKey ?? "", "aetheria.orbit", body.OrbitLegacyId ?? ""),
Mass = body.Mass,
Resources = ToBodyResources(body.Resources),
BodyRadiusMultiplier = body.BodyRadiusMultiplier,

View file

@ -102,6 +102,10 @@ Unity runtime commit DTOs now also carry typed `FactionKey` for loadout
entities, run entity snapshots, and faction relationship state. The old
`CorporationLegacyId` fields remain compatibility-only for older pending
commits; current Unity projection does not write them.
Run checkpoint commit DTOs carry typed `OrbitKey`, `ParentOrbitKey`, and
`BodyKey` for zone orbit/body snapshots. The old `OrbitLegacyId`,
`ParentLegacyId`, and `BodyLegacyId` fields remain compatibility-only for older
pending commits; current Unity projection does not write them.
The package runtime catalog snapshot indexes items by canonical item key; Unity
gameplay, HUD, inventory, trade, ship, and zone helper lookups use `ItemKey`
directly instead of deriving `ItemId` and searching by legacy GUID.

View file

@ -639,8 +639,8 @@ public class ActionGameManager : MonoBehaviour
.OrderBy(orbit => orbit.ID)
.Select(orbit => new AetheriaRuntimeOrbitSnapshotCommit
{
OrbitLegacyId = LegacyId(orbit.ID),
ParentLegacyId = LegacyId(orbit.Parent),
OrbitKey = OrbitKey(orbit.ID),
ParentOrbitKey = OrbitKey(orbit.Parent),
Distance = orbit.Distance,
Phase = orbit.Phase,
FixedPositionX = orbit.FixedPosition.x,
@ -657,7 +657,7 @@ public class ActionGameManager : MonoBehaviour
return zone.PlanetInstances.Values
.Select(planet => ProjectZoneBody(planet))
.Concat(zone.AsteroidBelts.Values.Select(belt => ProjectZoneBody(zone, belt)))
.OrderBy(body => body.BodyLegacyId)
.OrderBy(body => body.BodyKey)
.ToArray();
}
@ -665,10 +665,10 @@ public class ActionGameManager : MonoBehaviour
{
return new AetheriaRuntimeBodySnapshotCommit
{
BodyLegacyId = LegacyId(planet.ID),
BodyKey = BodyKey(planet.ID),
Kind = BodyKind(planet),
Name = planet.Name,
OrbitLegacyId = LegacyId(planet.OrbitId),
OrbitKey = OrbitKey(planet.OrbitId),
Mass = planet.Mass,
Resources = planet.Resources?
.OrderBy(pair => pair.Key)
@ -696,10 +696,10 @@ public class ActionGameManager : MonoBehaviour
{
return new AetheriaRuntimeBodySnapshotCommit
{
BodyLegacyId = LegacyId(belt.ID),
BodyKey = BodyKey(belt.ID),
Kind = "asteroid_belt",
Name = belt.Name,
OrbitLegacyId = LegacyId(belt.Orbit),
OrbitKey = OrbitKey(belt.Orbit),
Mass = belt.Mass,
Resources = belt.Resources?
.OrderBy(pair => pair.Key)
@ -1270,6 +1270,16 @@ public class ActionGameManager : MonoBehaviour
return id == Guid.Empty ? "" : $"aetheria.corporation:legacy:{id:D}";
}
private static string OrbitKey(Guid id)
{
return id == Guid.Empty ? "" : $"aetheria.orbit:legacy:{id:D}";
}
private static string BodyKey(Guid id)
{
return id == Guid.Empty ? "" : $"aetheria.body:legacy:{id:D}";
}
private static int ZoneIndex(GalaxyZone zone)
{
return CurrentGalaxy?.Zones == null || zone == null ? -1 : Array.IndexOf(CurrentGalaxy.Zones, zone);

View file

@ -341,6 +341,12 @@ namespace GameCult.Aetheria.State.Unity
[Key(5)]
public double FixedPositionY { get; set; }
[Key(6)]
public string OrbitKey { get; set; } = "";
[Key(7)]
public string ParentOrbitKey { get; set; } = "";
}
[MessagePackObject]
@ -384,6 +390,12 @@ namespace GameCult.Aetheria.State.Unity
[Key(12)]
public AetheriaRuntimeSunVisualCommit SunVisual { get; set; } = new AetheriaRuntimeSunVisualCommit();
[Key(13)]
public string BodyKey { get; set; } = "";
[Key(14)]
public string OrbitKey { get; set; } = "";
}
[MessagePackObject]