Rename zone-state orbit and body ids to keys

This commit is contained in:
Meta Vens 2026-06-16 17:03:59 +01:00
commit c0aec84af4
7 changed files with 131 additions and 27 deletions

Binary file not shown.

View file

@ -21,6 +21,7 @@ RequireKeyedOrbitRuntimeWrappers(root);
RequireNativeZoneKeyResolution(root);
RequireTypedZoneRuntimeCollections(root);
RequireTypedZoneConstructionKeys(root);
RequireTypedZoneStateSnapshotKeys(root);
RequireTypedAsteroidZoneApi(root);
RequireTypedFactionShellLinks(root);
RequireFactionKeyIdentity(root);
@ -1449,6 +1450,105 @@ static void RequireTypedZoneConstructionKeys(string root)
}
}
static void RequireTypedZoneStateSnapshotKeys(string root)
{
var checkedFiles = new[]
{
Path.Combine(root, "Aetheria.State", "Documents", "AetheriaRuntimeStateDocuments.cs"),
Path.Combine(root, "Aetheria.State", "AetheriaRuntimeCommitLogApplier.cs"),
Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCatalogSnapshot.cs"),
Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCatalogStore.cs")
};
var forbiddenSymbols = new[]
{
"public string OrbitId { get; set; } = \"\";",
"public string ParentId { get; set; } = \"\";",
"public string BodyId { get; set; } = \"\";",
"public AetheriaRuntimeOrbitSnapshot(string orbitId, string parentId",
"string bodyId,",
"string orbitId,",
"OrbitId = orbit.OrbitKey ?? \"\",",
"ParentId = orbit.ParentOrbitKey ?? \"\",",
"BodyId = body.BodyKey ?? \"\",",
"var orbitId = ReadFieldString(ref reader, orbitFields, 0);",
"var parentId = ReadFieldString(ref reader, orbitFields, 1);",
"var bodyId = ReadFieldString(ref reader, bodyFields, 0);",
"var orbitId = ReadFieldString(ref reader, bodyFields, 3);"
};
var hits = checkedFiles
.Where(File.Exists)
.SelectMany(path => File.ReadLines(path)
.Select((line, index) => new { Path = path, LineNumber = index + 1, Line = line }))
.Where(line => forbiddenSymbols.Any(symbol => line.Line.Contains(symbol, StringComparison.Ordinal)))
.Select(line => $"{Path.GetRelativePath(root, line.Path)}:{line.LineNumber}: {line.Line.Trim()}")
.ToArray();
if (hits.Length > 0)
{
throw new InvalidOperationException(
"Typed zone-state documents and runtime snapshots must name orbit/body identity as keys, not legacy ids: " +
string.Join("; ", hits));
}
var requiredSymbols = new Dictionary<string, string[]>
{
[Path.Combine(root, "Aetheria.State", "Documents", "AetheriaRuntimeStateDocuments.cs")] = new[]
{
"public string OrbitKey { get; set; } = \"\";",
"public string ParentOrbitKey { get; set; } = \"\";",
"public string BodyKey { get; set; } = \"\";"
},
[Path.Combine(root, "Aetheria.State", "AetheriaRuntimeCommitLogApplier.cs")] = new[]
{
"OrbitKey = orbit.OrbitKey ?? \"\",",
"ParentOrbitKey = orbit.ParentOrbitKey ?? \"\",",
"BodyKey = body.BodyKey ?? \"\",",
"OrbitKey = body.OrbitKey ?? \"\","
},
[Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCatalogSnapshot.cs")] = new[]
{
"public AetheriaRuntimeOrbitSnapshot(string orbitKey, string parentOrbitKey",
"OrbitKey = orbitKey;",
"ParentOrbitKey = parentOrbitKey;",
"public string OrbitKey { get; }",
"public string ParentOrbitKey { get; }",
"BodyKey = bodyKey;",
"OrbitKey = orbitKey;",
"public string BodyKey { get; }",
"public string OrbitKey { get; }"
},
[Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCatalogStore.cs")] = new[]
{
"var orbitKey = ReadFieldString(ref reader, orbitFields, 0);",
"var parentOrbitKey = ReadFieldString(ref reader, orbitFields, 1);",
"var bodyKey = ReadFieldString(ref reader, bodyFields, 0);",
"var orbitKey = ReadFieldString(ref reader, bodyFields, 3);",
"new AetheriaRuntimeOrbitSnapshot(",
"new AetheriaRuntimeBodySnapshot("
}
};
var missingSymbols = requiredSymbols
.Where(pair => !File.Exists(pair.Key) || pair.Value.Any(symbol => !File.ReadAllText(pair.Key).Contains(symbol, StringComparison.Ordinal)))
.SelectMany(pair =>
{
var text = File.Exists(pair.Key) ? File.ReadAllText(pair.Key) : "";
return pair.Value
.Where(symbol => !text.Contains(symbol, StringComparison.Ordinal))
.Select(symbol => $"{Path.GetRelativePath(root, pair.Key)}: missing {symbol}");
})
.ToArray();
if (missingSymbols.Length > 0)
{
throw new InvalidOperationException(
"Typed zone-state documents and runtime catalog readers must expose orbit/body key ownership explicitly: " +
string.Join("; ", missingSymbols));
}
}
static void RequireTypedAsteroidZoneApi(string root)
{
var zoneSourcePath = Path.Combine(root, "Assets", "Scripts", "ServerShared", "Zone.cs");

View file

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

View file

@ -290,10 +290,10 @@ public sealed class AetheriaDroppedPickupSnapshot
public sealed class AetheriaOrbitSnapshot
{
[Key(0)]
public string OrbitId { get; set; } = "";
public string OrbitKey { get; set; } = "";
[Key(1)]
public string ParentId { get; set; } = "";
public string ParentOrbitKey { get; set; } = "";
[Key(2)]
public double Distance { get; set; }
@ -309,7 +309,7 @@ public sealed class AetheriaOrbitSnapshot
public sealed class AetheriaBodySnapshot
{
[Key(0)]
public string BodyId { get; set; } = "";
public string BodyKey { get; set; } = "";
[Key(1)]
public string Kind { get; set; } = "";
@ -318,7 +318,7 @@ public sealed class AetheriaBodySnapshot
public string Name { get; set; } = "";
[Key(3)]
public string OrbitId { get; set; } = "";
public string OrbitKey { get; set; } = "";
[Key(4)]
public double Mass { get; set; }

View file

@ -129,6 +129,10 @@ and `MiningTool` now retain typed body-key runtime state directly, while
`Zone`, `Planet`, `AsteroidBelt`, and `Orbit` now own the runtime body/orbit
key surfaces used for projection, and `ActionGameManager` no longer formats or
resolves body/orbit keys locally while checkpointing or restoring state.
Typed `AetheriaZoneState` orbit/body snapshot rows now use `OrbitKey`,
`ParentOrbitKey`, and `BodyKey` property names all the way through the typed
document and runtime catalog readback surface; the old `...Id` names were only
legacy-shaped aliases for those key strings and are gone.
Orbit-targeting agent runtime also now retains typed orbit keys directly:
`PatrolOrbitsTask`, `MoveToOrbitState`, and `StationTowing` no longer own raw
orbit GUID targets, and `Zone` resolves orbit keys for agent orbit movement.

View file

@ -964,18 +964,18 @@ namespace GameCult.Aetheria.State.Unity
public sealed class AetheriaRuntimeOrbitSnapshot
{
public AetheriaRuntimeOrbitSnapshot(string orbitId, string parentId, double distance, double phase, double fixedPositionX, double fixedPositionY)
public AetheriaRuntimeOrbitSnapshot(string orbitKey, string parentOrbitKey, double distance, double phase, double fixedPositionX, double fixedPositionY)
{
OrbitId = orbitId;
ParentId = parentId;
OrbitKey = orbitKey;
ParentOrbitKey = parentOrbitKey;
Distance = distance;
Phase = phase;
FixedPositionX = fixedPositionX;
FixedPositionY = fixedPositionY;
}
public string OrbitId { get; }
public string ParentId { get; }
public string OrbitKey { get; }
public string ParentOrbitKey { get; }
public double Distance { get; }
public double Phase { get; }
public double FixedPositionX { get; }
@ -985,10 +985,10 @@ namespace GameCult.Aetheria.State.Unity
public sealed class AetheriaRuntimeBodySnapshot
{
public AetheriaRuntimeBodySnapshot(
string bodyId,
string bodyKey,
string kind,
string name,
string orbitId,
string orbitKey,
double mass,
int resourceCount,
int asteroidCount,
@ -996,10 +996,10 @@ namespace GameCult.Aetheria.State.Unity
int respawningAsteroidCount,
int asteroidMiningAccumulatorCount)
{
BodyId = bodyId;
BodyKey = bodyKey;
Kind = kind;
Name = name;
OrbitId = orbitId;
OrbitKey = orbitKey;
Mass = mass;
ResourceCount = resourceCount;
AsteroidCount = asteroidCount;
@ -1008,10 +1008,10 @@ namespace GameCult.Aetheria.State.Unity
AsteroidMiningAccumulatorCount = asteroidMiningAccumulatorCount;
}
public string BodyId { get; }
public string BodyKey { get; }
public string Kind { get; }
public string Name { get; }
public string OrbitId { get; }
public string OrbitKey { get; }
public double Mass { get; }
public int ResourceCount { get; }
public int AsteroidCount { get; }

View file

@ -700,15 +700,15 @@ namespace GameCult.Aetheria.State.Unity
for (var orbit = 0; orbit < count; orbit++)
{
var orbitFields = reader.ReadArrayHeader();
var orbitId = ReadFieldString(ref reader, orbitFields, 0);
var parentId = ReadFieldString(ref reader, orbitFields, 1);
var orbitKey = ReadFieldString(ref reader, orbitFields, 0);
var parentOrbitKey = ReadFieldString(ref reader, orbitFields, 1);
var distance = ReadFieldDouble(ref reader, orbitFields, 2);
var phase = ReadFieldDouble(ref reader, orbitFields, 3);
var fixedPosition = ReadFieldVector2(ref reader, orbitFields, 4);
SkipRemaining(ref reader, orbitFields, 5);
orbits[orbit] = new AetheriaRuntimeOrbitSnapshot(
orbitId,
parentId,
orbitKey,
parentOrbitKey,
distance,
phase,
fixedPosition.X,
@ -726,20 +726,20 @@ namespace GameCult.Aetheria.State.Unity
for (var body = 0; body < count; body++)
{
var bodyFields = reader.ReadArrayHeader();
var bodyId = ReadFieldString(ref reader, bodyFields, 0);
var bodyKey = ReadFieldString(ref reader, bodyFields, 0);
var kind = ReadFieldString(ref reader, bodyFields, 1);
var name = ReadFieldString(ref reader, bodyFields, 2);
var orbitId = ReadFieldString(ref reader, bodyFields, 3);
var orbitKey = ReadFieldString(ref reader, bodyFields, 3);
var mass = ReadFieldDouble(ref reader, bodyFields, 4);
var resourceCount = CountAndSkipFieldArray(ref reader, bodyFields, 5);
SkipFields(ref reader, bodyFields, 6, 10);
var asteroidSummary = ReadFieldAsteroidSummary(ref reader, bodyFields, 10);
SkipRemaining(ref reader, bodyFields, 11);
bodies[body] = new AetheriaRuntimeBodySnapshot(
bodyId,
bodyKey,
kind,
name,
orbitId,
orbitKey,
mass,
resourceCount,
asteroidSummary.Count,