From 5d5098aae611bdd6593fb8bae3890037dce0a7d9 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 16 Jun 2026 05:24:11 +0100 Subject: [PATCH] Persist dropped pickups in zone checkpoints --- .voidbot/state/aetheria.cc | Bin 145611 -> 145736 bytes Aetheria.State.Unity.Smoke/Program.cs | 32 ++++++++- Aetheria.State.Verify/Program.cs | 68 ++++++++++++++++++ .../AetheriaRuntimeCommitLogApplier.cs | 27 ++++++- .../AetheriaRuntimeStateDocuments.cs | 19 +++++ Assets/Scripts/Gameplay/ActionGameManager.cs | 30 +++++++- Assets/Scripts/Zone Display/ZoneRenderer.cs | 1 + .../Runtime/AetheriaRuntimeCatalogSnapshot.cs | 37 +++++++++- .../Runtime/AetheriaRuntimeCatalogStore.cs | 33 ++++++++- .../AetheriaRuntimeStateCommitDocument.cs | 31 ++++++++ docs/aetheria-perfect-machine-map.md | 24 ++++--- 11 files changed, 288 insertions(+), 14 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index d9942f39662e0f853d34cd84c8dde79bc8f88dc6..7b237ca2846077624fe35f750f19881f798e3b67 100644 GIT binary patch delta 1566 zcmZuxU1%It6m~Y6)}#S{QY$UegAYP+cVn70NfV8PRv&Dul17n5(YrGzySF=Y?|AQ> zY&IZE>AN5!%$o>C1yLeY+)|M~D)goL7V+H|DO5xs_1xK++1=vX%)R$~=bZ2R&bf8> z@K1jp{${Uqq_#3&Td6Hq7Z#tXf9M=d?vzWD@vYL;;l-IHdlActovHkB?R0#1VzG2; z`r4`c&);#*#~1%P-V?F|rW>LMyHa393l{2@G@uPL2wZ@Q1h_49+o9yb=;~*#&v@{w z^VG)JMH&uyxCV>sGNrn3PRWq)U*m2&3N>`NX+fC&5d4ydJ7ox^=7vjAhHdnv%T2co zOn6yg++a{3gU1Y8h4|+4Cwma0(p(!2rbSPTgmt7Z#aW$txnw)Ya9Rkj3xb7^xoy@& zP{=$8q=!D>4yDH&qorijY!yJ%q~QS;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Y-wA^zrEFG5PANqef@}ii%#I)KKsDU7*>`LTGAw8V}% zUsCELsT$bSH}7Is-v9TW!$-Cn7)TXTaBf?|{L^2(`Nv!~Xf)%(f^Z-!h1r(cx4(FQ z% + { + [Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeStateCommitDocument.cs")] = new[] + { + "AetheriaRuntimeDroppedPickupCommit", + "DroppedPickups" + }, + [Path.Combine(root, "Aetheria.State", "Documents", "AetheriaRuntimeStateDocuments.cs")] = new[] + { + "AetheriaDroppedPickupSnapshot", + "DroppedPickups" + }, + [Path.Combine(root, "Aetheria.State", "AetheriaRuntimeCommitLogApplier.cs")] = new[] + { + "ToDroppedPickups", + "DroppedPickups = ToDroppedPickups(zone.DroppedPickups)" + }, + [Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCatalogStore.cs")] = new[] + { + "ReadFieldDroppedPickups", + "AetheriaRuntimeDroppedPickupSnapshot" + }, + [Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCatalogSnapshot.cs")] = new[] + { + "AetheriaRuntimeDroppedPickupSnapshot", + "public IReadOnlyList DroppedPickups" + }, + [Path.Combine(root, "Assets", "Scripts", "Gameplay", "ActionGameManager.cs")] = new[] + { + "ProjectDroppedPickups", + "DroppedPickups = ProjectDroppedPickups(zone)" + }, + [Path.Combine(root, "Assets", "Scripts", "Zone Display", "ZoneRenderer.cs")] = new[] + { + "ActiveLoot" + }, + [Path.Combine(root, "Aetheria.State.Unity.Smoke", "Program.cs")] = new[] + { + "new AetheriaRuntimeDroppedPickupCommit", + "packageZones[0].DroppedPickups" + } + }; + + var missing = requiredFiles + .SelectMany(pair => + { + if (!File.Exists(pair.Key)) + return new[] { $"{Path.GetRelativePath(root, pair.Key)}: missing file" }; + + var text = 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 (missing.Length > 0) + { + throw new InvalidOperationException( + "Dropped pickup checkpoint state is incomplete: " + + string.Join("; ", missing)); + } +} + static void RequireInventoryLoadoutRestoreCommitAuthority(string root) { var actionGameManagerPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "ActionGameManager.cs"); diff --git a/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs b/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs index b6b76d678..afd52cb03 100644 --- a/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs +++ b/Aetheria.State/AetheriaRuntimeCommitLogApplier.cs @@ -273,7 +273,8 @@ public static class AetheriaRuntimeCommitLogApplier OwnerFactionIndex = zone.OwnerFactionIndex, EntityKeys = entityKeys.ToArray(), Orbits = ToOrbitSnapshots(zone.Orbits), - Bodies = ToBodySnapshots(zone.Bodies, run.RunId, zone.ZoneIndex) + Bodies = ToBodySnapshots(zone.Bodies, run.RunId, zone.ZoneIndex), + DroppedPickups = ToDroppedPickups(zone.DroppedPickups) }) .ConfigureAwait(false); zoneKeys.Add(zoneKey.ToString()); @@ -284,6 +285,30 @@ public static class AetheriaRuntimeCommitLogApplier await node.PutRunStateAsync(RunKey(run.RunId), run).ConfigureAwait(false); } + private static AetheriaDroppedPickupSnapshot[] ToDroppedPickups( + IReadOnlyList? pickups) + { + return (pickups ?? Array.Empty()) + .Select(pickup => new AetheriaDroppedPickupSnapshot + { + PickupIndex = pickup.PickupIndex, + Position = new AetheriaVector3 + { + X = pickup.PositionX, + Y = pickup.PositionY, + Z = pickup.PositionZ + }, + Velocity = new AetheriaVector3 + { + X = pickup.VelocityX, + Y = pickup.VelocityY, + Z = pickup.VelocityZ + }, + Item = ToLoadoutItem(pickup.Item) + }) + .ToArray(); + } + private static AetheriaOrbitSnapshot[] ToOrbitSnapshots( IReadOnlyList? orbits) { diff --git a/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs b/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs index a44effa48..5aa1c5bcc 100644 --- a/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs +++ b/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs @@ -265,6 +265,25 @@ public sealed class AetheriaZoneState [Key(7)] public AetheriaBodySnapshot[] Bodies { get; set; } = []; + + [Key(8)] + public AetheriaDroppedPickupSnapshot[] DroppedPickups { get; set; } = []; +} + +[MessagePackObject] +public sealed class AetheriaDroppedPickupSnapshot +{ + [Key(0)] + public int PickupIndex { get; set; } = -1; + + [Key(1)] + public AetheriaVector3 Position { get; set; } = new(); + + [Key(2)] + public AetheriaVector3 Velocity { get; set; } = new(); + + [Key(3)] + public AetheriaLoadoutItem Item { get; set; } = new(); } [MessagePackObject] diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 06cea354e..613bea880 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -661,10 +661,38 @@ public class ActionGameManager : MonoBehaviour Bodies = ProjectZoneBodies(zone), Entities = zone.Entities .Select((entity, index) => ProjectEntitySnapshot(zone, entity, index)) - .ToArray() + .ToArray(), + DroppedPickups = ProjectDroppedPickups(zone) }; } + private AetheriaRuntimeDroppedPickupCommit[] ProjectDroppedPickups(Zone zone) + { + if (Zone != zone || ZoneRenderer?.ActiveLoot == null) + return Array.Empty(); + + return ZoneRenderer.ActiveLoot + .Where(pickup => pickup != null && pickup.Item != null) + .Select((pickup, index) => + { + var gridObject = pickup.GetComponent(); + var position = pickup.transform.position; + var velocity = gridObject == null ? Vector3.zero : gridObject.Velocity; + return new AetheriaRuntimeDroppedPickupCommit + { + PickupIndex = index, + PositionX = position.x, + PositionY = position.y, + PositionZ = position.z, + VelocityX = velocity.x, + VelocityY = velocity.y, + VelocityZ = velocity.z, + Item = ProjectLoadoutItem(pickup.Item) + }; + }) + .ToArray(); + } + private static AetheriaRuntimeOrbitSnapshotCommit[] ProjectZoneOrbits(Zone zone) { return zone?.Orbits?.Values diff --git a/Assets/Scripts/Zone Display/ZoneRenderer.cs b/Assets/Scripts/Zone Display/ZoneRenderer.cs index d0933f547..bd0a06ab3 100644 --- a/Assets/Scripts/Zone Display/ZoneRenderer.cs +++ b/Assets/Scripts/Zone Display/ZoneRenderer.cs @@ -91,6 +91,7 @@ public class ZoneRenderer : MonoBehaviour private List _loot = new List(); public Zone Zone { get; private set; } + public IReadOnlyList ActiveLoot => _loot; public ItemManager ItemManager { get; set; } public Entity PerspectiveEntity diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs index b84ee4b51..482f59459 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogSnapshot.cs @@ -782,7 +782,8 @@ namespace GameCult.Aetheria.State.Unity int ownerFactionIndex, IReadOnlyList entityKeys, IReadOnlyList orbits, - IReadOnlyList bodies) + IReadOnlyList bodies, + IReadOnlyList droppedPickups) { Name = name; PositionX = positionX; @@ -793,6 +794,7 @@ namespace GameCult.Aetheria.State.Unity EntityKeys = entityKeys; Orbits = orbits; Bodies = bodies; + DroppedPickups = droppedPickups; } public string Name { get; } @@ -804,6 +806,39 @@ namespace GameCult.Aetheria.State.Unity public IReadOnlyList EntityKeys { get; } public IReadOnlyList Orbits { get; } public IReadOnlyList Bodies { get; } + public IReadOnlyList DroppedPickups { get; } + } + + public sealed class AetheriaRuntimeDroppedPickupSnapshot + { + public AetheriaRuntimeDroppedPickupSnapshot( + int pickupIndex, + double positionX, + double positionY, + double positionZ, + double velocityX, + double velocityY, + double velocityZ, + AetheriaRuntimeLoadoutItemSnapshot item) + { + PickupIndex = pickupIndex; + PositionX = positionX; + PositionY = positionY; + PositionZ = positionZ; + VelocityX = velocityX; + VelocityY = velocityY; + VelocityZ = velocityZ; + Item = item; + } + + public int PickupIndex { get; } + public double PositionX { get; } + public double PositionY { get; } + public double PositionZ { get; } + public double VelocityX { get; } + public double VelocityY { get; } + public double VelocityZ { get; } + public AetheriaRuntimeLoadoutItemSnapshot Item { get; } } public sealed class AetheriaRuntimeEntitySnapshot diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs index 060a318eb..eee6ec794 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeCatalogStore.cs @@ -491,7 +491,8 @@ namespace GameCult.Aetheria.State.Unity var entityKeys = ReadFieldStringArray(ref reader, fields, 5); var orbits = ReadFieldOrbitSnapshots(ref reader, fields, 6); var bodies = ReadFieldBodySnapshots(ref reader, fields, 7); - SkipRemaining(ref reader, fields, 8); + var droppedPickups = ReadFieldDroppedPickups(ref reader, fields, 8); + SkipRemaining(ref reader, fields, 9); return new AetheriaRuntimeZoneStateSnapshot( name, position.X, @@ -501,7 +502,35 @@ namespace GameCult.Aetheria.State.Unity ownerFactionIndex, entityKeys, orbits, - bodies); + bodies, + droppedPickups); + } + + private static IReadOnlyList ReadFieldDroppedPickups(ref MessagePackReader reader, int fields, int index) + { + if (index >= fields) return Array.Empty(); + var count = reader.ReadArrayHeader(); + var pickups = new AetheriaRuntimeDroppedPickupSnapshot[count]; + for (var pickup = 0; pickup < count; pickup++) + { + var pickupFields = reader.ReadArrayHeader(); + var pickupIndex = pickupFields > 0 ? ReadFieldInt32(ref reader, pickupFields, 0) : -1; + var position = ReadFieldVector3(ref reader, pickupFields, 1); + var velocity = ReadFieldVector3(ref reader, pickupFields, 2); + var item = ReadFieldLoadoutItem(ref reader, pickupFields, 3); + SkipRemaining(ref reader, pickupFields, 4); + pickups[pickup] = new AetheriaRuntimeDroppedPickupSnapshot( + pickupIndex, + position.X, + position.Y, + position.Z, + velocity.X, + velocity.Y, + velocity.Z, + item); + } + + return pickups; } private static AetheriaRuntimeEntitySnapshot ReadEntitySnapshotPayload(byte[] payload) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs index 7a3a51092..77ffa6ace 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateCommitDocument.cs @@ -322,6 +322,37 @@ namespace GameCult.Aetheria.State.Unity [Key(9)] public IReadOnlyList Bodies { get; set; } = Array.Empty(); + + [Key(10)] + public IReadOnlyList DroppedPickups { get; set; } = Array.Empty(); + } + + [MessagePackObject] + public sealed class AetheriaRuntimeDroppedPickupCommit + { + [Key(0)] + public int PickupIndex { get; set; } = -1; + + [Key(1)] + public double PositionX { get; set; } + + [Key(2)] + public double PositionY { get; set; } + + [Key(3)] + public double PositionZ { get; set; } + + [Key(4)] + public double VelocityX { get; set; } + + [Key(5)] + public double VelocityY { get; set; } + + [Key(6)] + public double VelocityZ { get; set; } + + [Key(7)] + public AetheriaRuntimeLoadoutItemCommit Item { get; set; } = new AetheriaRuntimeLoadoutItemCommit(); } [MessagePackObject] diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index f8dc024aa..2868c12fb 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -954,11 +954,15 @@ First Aetheria surfaces to publish: - Done: preserve entity contact rows for gathered info, hostility, and visible classification, so detection/contact state is typed snapshot data instead of only reactive runtime collections. + - Done: preserve dropped world-pickup rows in typed zone snapshots. Run + checkpoints now carry pickup index, position, velocity, item key, quality, + durability, quantity, and package readback through + `AetheriaRuntimeZoneStateSnapshot.DroppedPickups`. - Remaining: add typed documents/mappers for runtime object graphs, - typed behavior factory construction, remaining behavior-private state not - covered by progress, weapon, sensor, radiator, reactor, or capacitor rows, - and any catalog fields not covered by the stable scalar/fingerprint/ - payload pass. + restore/lowering of dropped pickups back into live scene objects, typed + behavior factory construction, remaining behavior-private state not covered + by progress, weapon, sensor, radiator, reactor, or capacitor rows, and any + catalog fields not covered by the stable scalar/fingerprint/payload pass. 4. Runtime cutover - Done: add a Unity-facing typed catalog read facade and smoke proving it can @@ -1418,8 +1422,9 @@ First Aetheria surfaces to publish: `ActionGameManager.CommitEntityDestroyed`. `EntityInstance` observes hull death and may spawn the local destruction effect, but gameplay owns equipment/cargo drop decisions, zone entity removal, and the typed run - checkpoint. Dropped world pickups are still presentation/runtime objects - until the runtime object graph pass gives them typed documents. + checkpoint. Dropped world pickups are now projected into typed zone + snapshot state; restoring/lowering those typed pickup rows back into live + scene objects remains future runtime object graph work. - Replace the next concrete uGUI screen with an Eve-owned surface. - Move the staged packages into the Eve repo once its worktree is clean, then import them back into Aetheria from Eve instead of carrying a local copy. @@ -1648,7 +1653,8 @@ First Aetheria surfaces to publish: the embedded package-owned read-only catalog opener, receiving the same package-owned runtime catalog read models without a MessagePack catalog cache, including typed item masks, interior masks, hardpoint definitions, - corporation/name-file links, and typed behavior payloads. It also proves the + corporation/name-file links, typed behavior payloads, and dropped world + pickup rows in zone snapshots. It also proves the embedded package can read provider-owned Eve surface documents from the same CultCache store. The smoke proves the Unity runtime state commit log can queue player-settings and run snapshot commands, the `Aetheria.State` node @@ -1757,7 +1763,9 @@ owns `CurrentEntity`, `DockingBay.DockedShip`, and checkpoint. Loot pickup follows the same rule: collision code reports the pickup opportunity, gameplay owns cargo storage and checkpoint. Entity destruction follows the same rule: instance code observes death, gameplay owns drop decisions, zone removal, and -checkpoint. Any +checkpoint. Dropped world pickups are typed zone-snapshot state, not only +renderer-local objects; restore/lowering work must consume that typed state +instead of rehydrating a parallel presentation list. Any predicate that still needs legacy DTO objects must earn that dependency by using behavior objects or simulation-only methods that typed facets do not yet expose.