diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index d9942f396..7b237ca28 100644 Binary files a/.voidbot/state/aetheria.cc and b/.voidbot/state/aetheria.cc differ diff --git a/Aetheria.State.Unity.Smoke/Program.cs b/Aetheria.State.Unity.Smoke/Program.cs index b37c78f23..7223d16b9 100644 --- a/Aetheria.State.Unity.Smoke/Program.cs +++ b/Aetheria.State.Unity.Smoke/Program.cs @@ -330,6 +330,24 @@ try } } }, + DroppedPickups = new[] + { + new AetheriaRuntimeDroppedPickupCommit + { + PickupIndex = 2, + PositionX = 9.0, + PositionY = 1.5, + PositionZ = -3.0, + VelocityX = 0.25, + VelocityY = -0.5, + VelocityZ = 2.0, + Item = new AetheriaRuntimeLoadoutItemCommit + { + ItemKey = "aetheria.item_definition:legacy:smoke:ore", + Quantity = 11 + } + } + }, Entities = new[] { new AetheriaRuntimeEntitySnapshotCommit @@ -727,6 +745,12 @@ try zone.Bodies[0].Asteroids[0].MiningAccumulators.Length == 1 && zone.Bodies[0].Asteroids[0].MiningAccumulators[0].MinerEntityKey == "global:aetheria.run_state.smoke-run.zone.0.entity.0.v1" && zone.Bodies[0].Asteroids[0].MiningAccumulators[0].Amount == 0.75 && + zone.DroppedPickups.Length == 1 && + zone.DroppedPickups[0].PickupIndex == 2 && + zone.DroppedPickups[0].Position.X == 9.0 && + zone.DroppedPickups[0].Velocity.Z == 2.0 && + zone.DroppedPickups[0].Item.ItemKey == "aetheria.item_definition:legacy:smoke:ore" && + zone.DroppedPickups[0].Item.Quantity == 11 && entity?.Equipment.Length == 1 && entity.FactionKey == "aetheria.corporation:legacy:smoke:faction" && entity.Equipment[0].Quality == 0.9 && @@ -875,6 +899,12 @@ try packageZones[0].Bodies[0].DamagedAsteroidCount != 1 || packageZones[0].Bodies[0].RespawningAsteroidCount != 1 || packageZones[0].Bodies[0].AsteroidMiningAccumulatorCount != 1 || + packageZones[0].DroppedPickups.Count != 1 || + packageZones[0].DroppedPickups[0].PickupIndex != 2 || + packageZones[0].DroppedPickups[0].PositionX != 9.0 || + packageZones[0].DroppedPickups[0].VelocityZ != 2.0 || + packageZones[0].DroppedPickups[0].Item.ItemKey != "aetheria.item_definition:legacy:smoke:ore" || + packageZones[0].DroppedPickups[0].Item.Quantity != 11 || packageEntities.Count != 1 || packageEntities[0].Name != "Unity Smoke Ship" || packageEntities[0].FactionKey != "aetheria.corporation:legacy:smoke:faction" || @@ -971,7 +1001,7 @@ Console.WriteLine($"Behavior payload sample: {behaviorHost.Name} {behaviorPayloa Console.WriteLine($"Behavior sample: {behaviorKind}"); Console.WriteLine($"Eve surface: {surface.Surface.Id}"); Console.WriteLine($"Package Eve surfaces: {packageSurfaces.Count}"); -Console.WriteLine("Runtime state commit log smoke: settings, loadouts, action-bar bindings, faction relationships, and run zone/entity snapshots queued, applied, and cleared"); +Console.WriteLine("Runtime state commit log smoke: settings, loadouts, action-bar bindings, faction relationships, and run zone/entity/pickup snapshots queued, applied, and cleared"); Console.WriteLine("Runtime Eve command log smoke: surface command queued separately from state commits"); static void AssertPendingCultCacheEnvelope(string path, string expectedSchemaId) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 57b604e0c..ce6bb4bdb 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -21,6 +21,7 @@ RequireWeaponGroupCommitAuthority(root); RequireInventoryDoubleClickTransferCommitAuthority(root); RequireLootPickupCommitAuthority(root); RequireEntityDestroyedCommitAuthority(root); +RequireDroppedPickupCheckpointState(root); RequireTradePurchaseCommitAuthority(root); RequireInventoryLoadoutRestoreCommitAuthority(root); RequireDockedCurrentShipCommitAuthority(root); @@ -474,6 +475,7 @@ Console.WriteLine("Weapon group authority: UI assignment flows through gameplay Console.WriteLine("Inventory transfer authority: UI transfer and drag/drop requests flow through gameplay checkpoint commits"); Console.WriteLine("Loot pickup authority: collision pickup requests flow through gameplay checkpoint commits"); Console.WriteLine("Entity destruction authority: hull-death observers flow through gameplay checkpoint commits"); +Console.WriteLine("Dropped pickup state: zone checkpoints carry typed dropped-pickup snapshots"); Console.WriteLine("Trade purchase authority: UI buy requests flow through gameplay checkpoint commits"); Console.WriteLine("Inventory loadout restore authority: UI restore requests flow through gameplay checkpoint commits"); Console.WriteLine("Docked current-ship authority: UI selection requests flow through gameplay checkpoint commits"); @@ -1223,6 +1225,72 @@ static void RequireEntityDestroyedCommitAuthority(string root) } } +static void RequireDroppedPickupCheckpointState(string root) +{ + var requiredFiles = new Dictionary + { + [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.