From 43655ca96dbdadc4c9995154bdaf75dd8bfd0cf4 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 16 Jun 2026 16:32:31 +0100 Subject: [PATCH] Keep zone asteroid helpers on typed keys --- .voidbot/state/aetheria.cc | Bin 183350 -> 183368 bytes Aetheria.State.Verify/Program.cs | 49 +++++++++++++++++++++++++++ Aetheria.State/README.md | 4 +++ Assets/Scripts/ServerShared/Zone.cs | 32 +++++++---------- docs/aetheria-perfect-machine-map.md | 7 ++-- 5 files changed, 69 insertions(+), 23 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 80b36b59a84b1bdfd4fd10f6bb73c0021a412457..64a272164c5e18e7423c66249c204b9fb5721efd 100644 GIT binary patch delta 1574 zcma)6&5ImG6sIeT*$)ha7^7n18{#1YJF`2Z?oQT-&XP6A5?zu-a4}#_cg=J;Jzbru z>K!MSMN|ZXii}YC2aH|D`q@y!E_!^?vX7QT6SO znICV=e0h^hK2=|;)vArg@UKHBhCh(&;d{oOpuVoq4A`@qT&2 zyIr0jXTBbGUzt9k2MG%**F?-JRB0v!4=Oa_=8Z17y!HA9)?r+SkVOfTKvNwG$@KtY z(FdjJK!J$CO@fvP2GC`;BtfRJ<~;_@eDX4jG>F!l%-5>=nIBQ!`_+5$Wkw}ay1<7> zh;Ew9!d8LI-r_hS_8Isg^Sf$xcPTAttlC2MAWZ_Qnf)&gpvPk#cW^_T7I$##E@KH? zNO@2kt+d=an@mQ61`6w-Lk1DwM9!AumL*vQCxWG#1AseM;3{Yh{)=h0Pcb=3TM_q* zCB~wvRJJMd+bid37VPR-{Tu~QT*SY8wT@c`NC#PMm^d=5HW2vva9hJy^m>>DHL#DBNCOIxnVuUqD`jECuQ=`)^Fzp%BsP7 zCL}vZ(;QnA((*V{QCJIYL@F2&=Tjb$%!`ETP=PbM3ai$zcB)gv$lRP$K8>$fU+0Qs z^o8uY^dX7e1iJAo=rHJqJYtZfDjZYIl~ZX;p@-UX?^78-gx}JXzW0uqckhsMVR%sZ zmCJmp_JaMdxFZTCmO(1k;6{IVbR= z6XrbkUaDo3bTwDhCN;tJx9Q}qIH4=n1-5U3~7=JMi_{}V~=Jyd?+`2YQ delta 1634 zcma)7-)me&6y{DB+ccOGG}4Bm<3lkE$)?$otceejk{UuQS!yjbAUJ#P+1+vP-r3HN z#0}^oA_a@6tT2UwZ~lZri)fKz*9d~oeN!m@3w;p8H_yzycXtH^UzR&(&Ybg|?|kR% zFE=K?yD@qDb8@s?Sz9WXD$A9fkAs>1&*XY;Sy}NGacDocR8D)#k-{_N-e2z)3)hN; z;BK)%=Dx8vZu}GV?}jS3e#xPG^(>vo<#5_zT%0}z|gynkvdE&o;2v@t6Lk2)}?6U zQ=xz=Ezzz@pM^2w?cajlYd(L?@HkRbnnd$9(1?c)A(I>fV-kpHtxL}$p!1l~VcK?> z+@UTc?Zhkrt>!612vTtLhS;BT^r}QJ$?hiTs&}2wPU~treQ*~2bE6MEPtnadetQ{W5pvzlZ|&gs;HjQ36>%@57zPNSd6J+a6CByIB+Nk zCxQ3e|VaksQnyLO~jQK{gR=0==)GXVF8)BCSX;YzZhhnBa~L8N5~tbmHj03a%r=Z1$tXk8 z|6qE>R&SB1V9!2#GC1Lv0`P3cMTNzx_x=lj7{aLuk?4`O>^Kqilk0O0&Kz<%^LIbNu&EuXPV zhS2ou)_@dGedQ(XmhP8M;qK#3TG03s{$oH^Ch~p1Y^M*%iNo2k|LD+h+xn3V@?F2W onr;8b?Dhc>nfdu8{}*5%9*}o(Q@QLs@4odDIhe?8XHM_@4a@XN(f|Me diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 832248105..14a434ca8 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -19,6 +19,7 @@ RequireTypedOrbitalEntityOrbitKeys(root); RequireTypedOrbitConsumerKeys(root); RequireKeyedOrbitRuntimeWrappers(root); RequireNativeZoneKeyResolution(root); +RequireTypedAsteroidZoneApi(root); RequireTypedFactionShellLinks(root); RequireFactionKeyIdentity(root); RequireEveRuntimeBootstrap(root); @@ -1262,6 +1263,54 @@ static void RequireNativeZoneKeyResolution(string root) } } +static void RequireTypedAsteroidZoneApi(string root) +{ + var zoneSourcePath = Path.Combine(root, "Assets", "Scripts", "ServerShared", "Zone.cs"); + var zoneSource = File.Exists(zoneSourcePath) + ? File.ReadAllText(zoneSourcePath) + : throw new InvalidOperationException("Cannot verify typed asteroid Zone API; Zone source is missing."); + + var forbiddenSymbols = new[] + { + "public int NearestAsteroid(Guid planetDataID, float2 position)", + "public bool AsteroidExists(Guid planetDataID, int asteroid)", + "public void MineAsteroid(Entity miner, Guid asteroidBelt, int asteroid, float damage, float efficiency, float penetration)", + "BeltUpdates.Add(Task.Run(() => UpdateAsteroidTransforms(belt.Key)));", + "private void UpdateAsteroidTransforms(Guid planetDataID)", + "MineAsteroid(miner, belt.ID, asteroid, damage, efficiency, penetration);" + }; + var hits = forbiddenSymbols + .Where(symbol => zoneSource.Contains(symbol, StringComparison.Ordinal)) + .Select(symbol => $"Assets/Scripts/ServerShared/Zone.cs: contains {symbol}") + .ToArray(); + if (hits.Length > 0) + { + throw new InvalidOperationException( + "Zone asteroid helpers must keep typed body-key or runtime-object authority rather than Guid overloads: " + + string.Join("; ", hits)); + } + + var requiredSymbols = new[] + { + "foreach (var belt in AsteroidBelts.Values)", + "BeltUpdates.Add(Task.Run(() => UpdateAsteroidTransforms(belt)));", + "public int NearestAsteroid(string asteroidBeltKey, float2 position)", + "if (!TryGetAsteroidBelt(asteroidBeltKey, out var belt))", + "public bool AsteroidExists(string asteroidBeltKey, int asteroid)", + "private void UpdateAsteroidTransforms(AsteroidBelt belt)", + "public void MineAsteroid(Entity miner, string asteroidBeltKey, int asteroid, float damage, float efficiency, float penetration)" + }; + var missingSymbols = requiredSymbols + .Where(symbol => !zoneSource.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingSymbols.Length > 0) + { + throw new InvalidOperationException( + "Zone asteroid helpers must route through typed body keys or runtime belt objects: " + + string.Join(", ", missingSymbols)); + } +} + static void RequireFactionKeyIdentity(string root) { var checkedFiles = new[] diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index 87f4d0ded..6bccea6ec 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -150,6 +150,10 @@ instead of reading a raw wrapper orbit GUID. body and orbit lookups resolve through key-indexed runtime dictionaries rather than reparsing GUIDs from `BodyKey` or `OrbitKey` strings before touching the Guid-indexed substrate. +The live asteroid helper surface follows the same rule: nearest-asteroid, +asteroid-exists, transform-update, and mining paths now use typed body keys or +runtime `AsteroidBelt` objects directly instead of Guid asteroid-belt helper +overloads. 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. diff --git a/Assets/Scripts/ServerShared/Zone.cs b/Assets/Scripts/ServerShared/Zone.cs index ca4a70a38..ee59cce19 100644 --- a/Assets/Scripts/ServerShared/Zone.cs +++ b/Assets/Scripts/ServerShared/Zone.cs @@ -173,11 +173,11 @@ public class Zone orbit.Value.Velocity = (orbit.Value.Position - orbit.Value.PreviousPosition) / deltaTime; } - foreach (var belt in AsteroidBelts) + foreach (var belt in AsteroidBelts.Values) { - Array.Copy(belt.Value.NewTransforms, belt.Value.Transforms, belt.Value.Transforms.Length); - belt.Value.OrbitPosition = belt.Value.NewOrbitPosition; - BeltUpdates.Add(Task.Run(() => UpdateAsteroidTransforms(belt.Key))); + Array.Copy(belt.NewTransforms, belt.Transforms, belt.Transforms.Length); + belt.OrbitPosition = belt.NewOrbitPosition; + BeltUpdates.Add(Task.Run(() => UpdateAsteroidTransforms(belt))); } foreach(var agent in Agents) @@ -245,9 +245,10 @@ public class Zone : float2.zero; } - public int NearestAsteroid(Guid planetDataID, float2 position) + public int NearestAsteroid(string asteroidBeltKey, float2 position) { - var belt = AsteroidBelts[planetDataID]; + if (!TryGetAsteroidBelt(asteroidBeltKey, out var belt)) + return -1; var asteroidPositions = belt.Transforms; int nearest = 0; @@ -255,7 +256,7 @@ public class Zone for (int i = 0; i < belt.AsteroidCount; i++) { var dist = lengthsq(asteroidPositions[i].xz - position); - if (AsteroidExists(planetDataID, i) && dist < nearestDistance) + if (belt.ContainsAsteroid(i) && dist < nearestDistance) { nearest = i; nearestDistance = dist; @@ -265,17 +266,13 @@ public class Zone return nearest; } - public bool AsteroidExists(Guid planetDataID, int asteroid) => AsteroidBelts[planetDataID].ContainsAsteroid(asteroid); - public bool AsteroidExists(string asteroidBeltKey, int asteroid) { return TryGetAsteroidBelt(asteroidBeltKey, out var belt) && belt.ContainsAsteroid(asteroid); } - private void UpdateAsteroidTransforms(Guid planetDataID) + private void UpdateAsteroidTransforms(AsteroidBelt belt) { - var belt = AsteroidBelts[planetDataID]; - belt.NewOrbitPosition = GetOrbitPosition(belt.Orbit.ParentOrbitKey); for (var i = 0; i < belt.AsteroidCount; i++) { @@ -298,9 +295,10 @@ public class Zone } } - public void MineAsteroid(Entity miner, Guid asteroidBelt, int asteroid, float damage, float efficiency, float penetration) + public void MineAsteroid(Entity miner, string asteroidBeltKey, int asteroid, float damage, float efficiency, float penetration) { - var belt = AsteroidBelts[asteroidBelt]; + if (!TryGetAsteroidBelt(asteroidBeltKey, out var belt)) + return; //var asteroidTransform = belt.Transforms[asteroid]; var size = belt.GetAsteroid(asteroid).Size; @@ -337,12 +335,6 @@ public class Zone } } - public void MineAsteroid(Entity miner, string asteroidBeltKey, int asteroid, float damage, float efficiency, float penetration) - { - if (TryGetAsteroidBelt(asteroidBeltKey, out var belt)) - MineAsteroid(miner, belt.ID, asteroid, damage, efficiency, penetration); - } - public SecurityLevel GetSecurityLevel(float2 pos) { if (GalaxyZone.Owner==null) return SecurityLevel.Open; diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index c9b084781..c5367460a 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -1377,9 +1377,10 @@ First Aetheria surfaces to publish: runtime wrappers no longer publish separate wrapper orbit GUID fields either; they retain `OrbitKey` plus their runtime `Orbit` object. `Zone`'s key-facing lookup surface also resolves through native key-indexed runtime - dictionaries instead of reparsing GUIDs from key strings. Remaining broader - simulation paths still derive legacy GUIDs until those structures move to - typed keys. + dictionaries instead of reparsing GUIDs from key strings. Zone asteroid + helpers now also route through typed body keys or runtime `AsteroidBelt` + objects instead of Guid overloads. Remaining broader simulation paths still + derive legacy GUIDs until those structures move to typed keys. - Done: delete the `ItemInstance.ItemId` legacy-GUID projection; diagnostics now report `ItemKey` so item instances expose only typed item-key identity. - Done: delete `Entity`/`EquippedCargoBay` cargo and consumable GUID lookup