From c0aec84af471fa64d707b6afd2642b7c5cf92391 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 16 Jun 2026 17:03:59 +0100 Subject: [PATCH] Rename zone-state orbit and body ids to keys --- .voidbot/state/aetheria.cc | Bin 186189 -> 187247 bytes Aetheria.State.Verify/Program.cs | 100 ++++++++++++++++++ .../AetheriaRuntimeCommitLogApplier.cs | 8 +- .../AetheriaRuntimeStateDocuments.cs | 8 +- Aetheria.State/README.md | 4 + .../Runtime/AetheriaRuntimeCatalogSnapshot.cs | 22 ++-- .../Runtime/AetheriaRuntimeCatalogStore.cs | 16 +-- 7 files changed, 131 insertions(+), 27 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index bfbb96a2954d354c9bd31a080ae3fd7160225571..47052ae88e6e6874f2e96896dc898e8b7452a7cd 100644 GIT binary patch delta 1609 zcmZuxL5mzk6t+5JR-Kqda4~2WUoKgKGvg-No$T&KbWeK_moPzG5UuX6=`Odss;#P? zN#`<<5j_NzIA|YCKy*b7A$o`oQB?H0iRf`fM8%`v9}w|X_sr}XJ>Ier3%_2#CgvBUK z0f7{(@xB*P9`C$vQ51_Q7dDv3NvaB}J*0*2&*9s;Hq_Wx+DHuNWtFkiCc^AWc9@{T zW0p!m0K-g{Fds(sfUkJl)KD7(5$|B8k$kc%n9?Cnz>}h#YA!|N!xvM;;qoD|bM@(v z8jz@z8YLVB=Cjuw=+$*dElQg+RLP32p)J*@^ipX&mQ)mLqeRG3*MRASc^pkZN6IQO z?`=g|ty~t;4!0S{_CEH3VZzef`KZ;i_K3RA^(H*Yw59=Dr`~3Xi;87Pgt`%{fs20F zA{fNQEl2xZw2KAQ%f?ld{JF4#zQ8GEtxD`ckuq?x>eT0W2*%os>?mz6`g>&c7_JnyB#iA0 z9qCawji|Eyixh-}2w~Bum>MrcBe3!6*4~kd3n=5igvTD$I2Q$F+hd>^jT=|6k3y+V zv$p=}j+cf9r^y%h=1a?D#(BP&zC-tclHIcZlGKg34slkFPFv9urf|dx8HYz^$$_Q( z=kLgKMYQjqzHMOlwDs6rz=6;jsoN1|XA`NBUD3vNh{pD4V;zxgRAKBKjX1@)!6Szb z57s}PD-c_&hzO{Jx0y&Tu~sFl2n-O{i&Up4V&N=VtaskUE&J^Sa`gVm>OFO0W6RJ04Lm>m>jHV% zA#~V(jU2BW`84K%!p@aqrKGGAF4&bq3QJ$Va^o@?-ni_TdUa2_!T0+f*j?6(lg<9+ r?q##M#I3$RZ{2j_-49FU>)&oVy~*X${BgVQhv#oOU*Emwc6s9;1U5#` delta 1022 zcmZXT!D|yi6vo|cYL!%|&|1NRa}p{^NSbWg=2j3ah*;Z-5WGxxC&{#%nPq0SYfcdb zrN^4XLd8R&BB-b*7Zec>QZHhAEEPQX2ly8VzS-TRhn{x#o450R-#7FAe#riKn|;4) zj#@RVTC-*gmC{^&%b4hWGdBlXb$VKBp|@|I?)gJvurO0C#>Hncm(9JgM^l+-Dr0;c z2{%1+BK&v3;N8Q!x5O${d4)xjD9V}$HwjZn_)O6@L5v4TDlUjbToCDjZPHMmHFXaj8<5-Ge?gh^ODd>5P65x_<$pbim 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 + { + [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"); diff --git a/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs b/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs index 98923425f..9ba45d730 100644 --- a/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs +++ b/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs @@ -315,8 +315,8 @@ public static class AetheriaRuntimeCommitLogApplier return (orbits ?? Array.Empty()) .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()) .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, diff --git a/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs b/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs index 78c348545..8c8c95da0 100644 --- a/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs +++ b/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs @@ -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; } diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index 0d7e05962..eb7c2e015 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -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. diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs index 854d59d35..df0865a7a 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs @@ -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; } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs index 5a31ccb27..397b8d596 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs @@ -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,