From be92f4c7af5210cae1562da9c98122dfbf1a807a Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 13 Jul 2026 15:23:35 +0100 Subject: [PATCH] Make Terminus salvage collection authoritative --- .../AetheriaDaemonLoadoutGenerator.cs | 3 +- .../AetheriaDaemonZoneGenerator.cs | 3 +- Aetheria.State.Daemon/Program.cs | 8 ++- .../AetheriaRuntimeStateDocuments.cs | 3 ++ .../Tests/DaemonRuntimeDocumentTests.cs | 27 +++++++++- .../AetheriaRuntimeDaemonOperations.cs | 22 +++++++- .../AetheriaRuntimeDaemonSimulation.cs | 51 +++++++++++-------- .../AetheriaRuntimeDaemonSoaDocuments.cs | 1 + .../AetheriaRuntimeDaemonSoaFramePublisher.cs | 17 +++++++ .../AetheriaRuntimePickupTransactions.cs | 5 +- .../AetheriaRuntimeSnapshotDocuments.cs | 3 ++ docs/aetheria-perfect-machine-map.md | 12 +++-- 12 files changed, 124 insertions(+), 31 deletions(-) diff --git a/Aetheria.State.Daemon/AetheriaDaemonLoadoutGenerator.cs b/Aetheria.State.Daemon/AetheriaDaemonLoadoutGenerator.cs index e3bf999de..c5483c618 100644 --- a/Aetheria.State.Daemon/AetheriaDaemonLoadoutGenerator.cs +++ b/Aetheria.State.Daemon/AetheriaDaemonLoadoutGenerator.cs @@ -73,7 +73,8 @@ public sealed class AetheriaDaemonLoadoutGenerator } var cargoBay = AddFreeSpaceItem(hull, availabilityFactionKey, occupied, slots, 3, item => - string.Equals(item.Category, AetheriaRuntimeItemCategories.CargoBay, StringComparison.Ordinal)); + string.Equals(item.Category, AetheriaRuntimeItemCategories.CargoBay, StringComparison.Ordinal) && + item.InteriorOccupiedCells >= 8); AddFreeSpaceItem(hull, availabilityFactionKey, occupied, slots, 2, item => IsGear(item) && HasBehavior(item, "Reactor")); AddFreeSpaceItem(hull, availabilityFactionKey, occupied, slots, 2, item => diff --git a/Aetheria.State.Daemon/AetheriaDaemonZoneGenerator.cs b/Aetheria.State.Daemon/AetheriaDaemonZoneGenerator.cs index 1ed940500..08ee05e7a 100644 --- a/Aetheria.State.Daemon/AetheriaDaemonZoneGenerator.cs +++ b/Aetheria.State.Daemon/AetheriaDaemonZoneGenerator.cs @@ -85,12 +85,13 @@ internal static class AetheriaDaemonZoneGenerator GravityTerrainDepthExponent = 1.18, GravityTerrainBoundaryFog = 0.25, GravityTerrainWaveFrequency = 0.55, + NextPickupIndex = 1, DroppedPickups = [ new AetheriaDroppedPickupSnapshot { PickupIndex = 0, - Position = Vec3(-40, 0, -29), + Position = Vec3(-50, 0, 40), Velocity = Vec3(0, 0, 0), Item = new AetheriaLoadoutItem { ItemKey = "scrap-metal", Quantity = 1 } } diff --git a/Aetheria.State.Daemon/Program.cs b/Aetheria.State.Daemon/Program.cs index 3296ddab6..ad38f152f 100644 --- a/Aetheria.State.Daemon/Program.cs +++ b/Aetheria.State.Daemon/Program.cs @@ -2738,7 +2738,13 @@ static async Task ToRuntimeZoneAsync( GravityTerrainDepthExponent = zone.GravityTerrainDepthExponent, GravityTerrainBoundaryFog = zone.GravityTerrainBoundaryFog, GravityTerrainWaveFrequency = zone.GravityTerrainWaveFrequency, - SimulationTimeSeconds = zone.SimulationTimeSeconds + SimulationTimeSeconds = zone.SimulationTimeSeconds, + NextPickupIndex = Math.Max( + zone.NextPickupIndex, + (zone.DroppedPickups ?? Array.Empty()) + .Select(pickup => pickup?.PickupIndex ?? -1) + .DefaultIfEmpty(-1) + .Max() + 1) }; } diff --git a/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs b/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs index c337c481c..0982cacda 100644 --- a/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs +++ b/Aetheria.State/Documents/AetheriaRuntimeStateDocuments.cs @@ -290,6 +290,9 @@ public sealed class AetheriaZoneState [Key(14)] public double SimulationTimeSeconds { get; set; } + + [Key(15)] + public int NextPickupIndex { get; set; } } [MessagePackObject] diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index 082bdde4e..0be0f6ab3 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -2636,6 +2636,19 @@ public class DaemonRuntimeDocumentTests VelocityX = 5, VelocityY = 6, IsActive = true, + CargoContents = new[] + { + new AetheriaRuntimeCargoBayLoadoutCommit + { + Items = new[] + { + new AetheriaRuntimeLoadoutItemSlotCommit + { + Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "ore", Quantity = 2 } + } + } + } + }, Contacts = new[] { new AetheriaRuntimeEntityContactCommit @@ -2680,7 +2693,7 @@ public class DaemonRuntimeDocumentTests Assert.AreEqual(AetheriaRuntimeDaemonSoaBackends.MemoryMappedFile, view.Backend); Assert.AreEqual(1, view.Buffers.Count); Assert.IsFalse(view.Buffers[0].ObserverWritable); - Assert.AreEqual(11, view.Columns.Count); + Assert.AreEqual(12, view.Columns.Count); Assert.AreEqual(1, view.RenderGroups.Count); Assert.AreEqual(3, view.RenderGroups[0].InstanceCount); Assert.IsTrue(view.Identities.Any(identity => @@ -2692,6 +2705,7 @@ public class DaemonRuntimeDocumentTests var index = AetheriaRuntimeDaemonSoaViewIndex.Build(view); Assert.IsTrue(index.IsValid, string.Join("\n", index.ValidationErrors)); Assert.IsTrue(index.TryGetFirstColumnOfKind(AetheriaRuntimeDaemonSoaColumnKinds.EntityIndex, out var entityIndex)); + Assert.IsTrue(index.TryGetFirstColumnOfKind(AetheriaRuntimeDaemonSoaColumnKinds.CargoQuantity, out var cargoQuantity)); Assert.IsTrue(index.TryGetFirstColumnOfKind(AetheriaRuntimeDaemonSoaColumnKinds.Position, out var position)); Assert.IsTrue(index.TryGetFirstColumnOfKind(AetheriaRuntimeDaemonSoaColumnKinds.Velocity, out var velocity)); Assert.IsTrue(index.TryGetFirstColumnOfKind(AetheriaRuntimeDaemonSoaColumnKinds.RenderVisibility, out var visibility)); @@ -2700,6 +2714,9 @@ public class DaemonRuntimeDocumentTests using var accessor = memory.CreateViewAccessor(0, view.Buffers[0].ByteLength, MemoryMappedFileAccess.Read); Assert.AreEqual(3, accessor.ReadInt32(entityIndex.AbsoluteByteOffset)); Assert.AreEqual(7, accessor.ReadInt32(entityIndex.AbsoluteByteOffset + entityIndex.Column.ElementStride)); + Assert.AreEqual(0, accessor.ReadInt32(cargoQuantity.AbsoluteByteOffset)); + Assert.AreEqual(2, accessor.ReadInt32(cargoQuantity.AbsoluteByteOffset + cargoQuantity.Column.ElementStride)); + Assert.AreEqual(0, accessor.ReadInt32(cargoQuantity.AbsoluteByteOffset + cargoQuantity.Column.ElementStride * 2)); Assert.AreEqual(-2f, accessor.ReadSingle(position.AbsoluteByteOffset), 0.0001f); Assert.AreEqual(-8f, accessor.ReadSingle(position.AbsoluteByteOffset + 8), 0.0001f); Assert.AreEqual(12f, accessor.ReadSingle(position.AbsoluteByteOffset + position.Column.ElementStride), 0.0001f); @@ -4671,6 +4688,14 @@ public class DaemonRuntimeDocumentTests Assert.AreEqual(1, undockResult.Intents.Docking.Count); Assert.IsTrue(undockResult.Intents.Docking[0].Undock); CollectionAssert.DoesNotContain(undockRun.Zones[0].Entities[1].DockingBayAssignments, 0); + var undockedActor = undockRun.Zones[0].Entities[0]; + var dockParent = undockRun.Zones[0].Entities[1]; + Assert.That( + Math.Sqrt(Math.Pow(undockedActor.PositionX - dockParent.PositionX, 2) + + Math.Pow(undockedActor.PositionZ - dockParent.PositionZ, 2)), + Is.EqualTo(72).Within(0.001)); + Assert.AreEqual(0, undockedActor.VelocityX); + Assert.AreEqual(0, undockedActor.VelocityY); var wormholeRun = RunWithTwoEntities(); wormholeRun.Zones[0].AdjacentZoneIndices = new[] { 2 }; diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs index 7616c1ec7..433a30a3b 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs @@ -1601,10 +1601,28 @@ namespace GameCult.Aetheria.State.Verse AetheriaRuntimeRunCheckpointCommit run, string actorEntityKey) { - if (!TryResolveEntity(run, actorEntityKey, out var zoneIndex, out var actorIndex, out _)) + if (!TryResolveEntity(run, actorEntityKey, out var zoneIndex, out var actorIndex, out var actor)) + return false; + var zone = (run.Zones ?? Array.Empty()) + .FirstOrDefault(candidate => candidate != null && candidate.ZoneIndex == zoneIndex); + var parent = (zone?.Entities ?? Array.Empty()) + .FirstOrDefault(entity => entity != null && + ((entity.ChildEntityIndices ?? Array.Empty()).Contains(actorIndex) || + (entity.DockingBayAssignments ?? Array.Empty()).Contains(actorIndex))); + if (parent == null || !RemoveChildReferenceFromZone(run, zoneIndex, actorIndex)) return false; - return RemoveChildReferenceFromZone(run, zoneIndex, actorIndex); + var directionLength = Math.Sqrt( + parent.DirectionX * parent.DirectionX + parent.DirectionY * parent.DirectionY); + var directionX = directionLength < 0.001 ? 0 : parent.DirectionX / directionLength; + var directionZ = directionLength < 0.001 ? 1 : parent.DirectionY / directionLength; + actor.PositionX = parent.PositionX + directionX * 72; + actor.PositionZ = parent.PositionZ + directionZ * 72; + actor.VelocityX = 0; + actor.VelocityY = 0; + actor.DirectionX = directionX; + actor.DirectionY = directionZ; + return true; } private static bool IsChildReferencedInZone( diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs index b02f9f917..bf9701bc7 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs @@ -56,8 +56,8 @@ namespace GameCult.Aetheria.State.Verse foreach (var movement in intents?.Movements ?? Enumerable.Empty()) ApplyMovementIntent(run, entities, movement, settings); StepTractorPower(entities, deltaSeconds); - var worldStep = StepWorldPhysics(zone, entities, deltaSeconds, worldPhysics); - ResolvePickupContacts(run, zone, entities, worldStep, catalog, frameId); + StepWorldPhysics(zone, entities, deltaSeconds, worldPhysics); + ResolveTractorCollections(run, zone, entities, catalog, frameId); StepCombat(run, zone, entities, intents, deltaSeconds, settings, physicalPayloadPhysics, catalog, frameId, simulationTimeSeconds); AetheriaRuntimeMiningSimulation.Step(run, zone, entities, intents, catalog, frameId, simulationTimeSeconds, deltaSeconds); @@ -146,32 +146,40 @@ namespace GameCult.Aetheria.State.Verse return result; } - private static void ResolvePickupContacts( + private static void ResolveTractorCollections( AetheriaRuntimeRunCheckpointCommit run, AetheriaRuntimeZoneSnapshotCommit zone, IReadOnlyList entities, - AetheriaRuntimeWorldStep worldStep, AetheriaRuntimeCatalogSnapshot? catalog, long frameId) { - foreach (var contact in worldStep.Contacts.Where(contact => contact.PickupIndex >= 0)) + foreach (var entity in entities.Where(value => + value != null && value.IsActive && value.TractorPower > 0.001)) { - var entityIndex = Math.Max(contact.EntityAIndex, contact.EntityBIndex); - var entity = entities.FirstOrDefault(value => value.EntityIndex == entityIndex && value.IsActive); - var pickup = (zone.DroppedPickups ?? Array.Empty()) - .FirstOrDefault(value => value != null && value.PickupIndex == contact.PickupIndex); - if (entity == null || pickup == null) continue; - if (AetheriaRuntimePickupTransactions.TryCollect(zone, entity, pickup.PickupIndex, catalog, requireRange: false)) + foreach (var pickup in (zone.DroppedPickups ?? Array.Empty()) + .Where(value => value != null) + .ToArray()) { - AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit { EventId = $"frame:{frameId}:zone:{zone.ZoneIndex}:entity:{entity.EntityIndex}:pickup:{pickup.PickupIndex}:collected", Kind = "pickup.collected", FrameId = frameId, ZoneIndex = zone.ZoneIndex, TargetEntityIndex = entity.EntityIndex, PickupIndex = pickup.PickupIndex, ItemKey = pickup.Item?.ItemKey ?? "", ScalarValue = Math.Max(1, pickup.Item?.Quantity ?? 1) }); - continue; + if (!AetheriaRuntimePickupTransactions.TryCollect( + zone, + entity, + pickup.PickupIndex, + catalog, + requireRange: true, + collectionRange: 75)) + continue; + AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit + { + EventId = $"frame:{frameId}:zone:{zone.ZoneIndex}:entity:{entity.EntityIndex}:pickup:{pickup.PickupIndex}:collected", + Kind = "pickup.collected", + FrameId = frameId, + ZoneIndex = zone.ZoneIndex, + TargetEntityIndex = entity.EntityIndex, + PickupIndex = pickup.PickupIndex, + ItemKey = pickup.Item?.ItemKey ?? "", + ScalarValue = Math.Max(1, pickup.Item?.Quantity ?? 1) + }); } - AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit { EventId = $"frame:{frameId}:zone:{zone.ZoneIndex}:entity:{entity.EntityIndex}:pickup:{pickup.PickupIndex}:rejected", Kind = "pickup.rejected", FrameId = frameId, ZoneIndex = zone.ZoneIndex, TargetEntityIndex = entity.EntityIndex, PickupIndex = pickup.PickupIndex, ItemKey = pickup.Item?.ItemKey ?? "", ScalarValue = Math.Max(1, pickup.Item?.Quantity ?? 1) }); - var dx = pickup.PositionX - entity.PositionX; var dz = pickup.PositionZ - entity.PositionZ; - var length = Math.Sqrt(dx * dx + dz * dz); - if (length < 0.001) { dx = 1; dz = 0; length = 1; } - pickup.VelocityX += dx / length * 25; - pickup.VelocityZ += dz / length * 25; } } @@ -1239,7 +1247,9 @@ namespace GameCult.Aetheria.State.Verse } var pickups = (zone.DroppedPickups ?? Array.Empty()).ToList(); - var nextPickupIndex = pickups.Count == 0 ? 0 : pickups.Max(value => value.PickupIndex) + 1; + var nextPickupIndex = Math.Max( + zone.NextPickupIndex, + pickups.Select(value => value.PickupIndex).DefaultIfEmpty(-1).Max() + 1); void Drop(AetheriaRuntimeLoadoutItemCommit item, string sourceKind, int sourceIndex) { var velocity = DestructionVelocity(run.GenerationSeed, destructionId, @@ -1287,6 +1297,7 @@ namespace GameCult.Aetheria.State.Verse if (slot?.Item != null) Drop(slot.Item, "cargo", cargoIndex); cargoIndex++; } + zone.NextPickupIndex = nextPickupIndex; zone.DroppedPickups = pickups; target.Equipment = Array.Empty(); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaDocuments.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaDocuments.cs index ea32e91a3..ec160fa5a 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaDocuments.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaDocuments.cs @@ -40,6 +40,7 @@ namespace GameCult.Aetheria.State.Verse public const string RenderScale = "render.scale"; public const string RenderVisibility = "render.visibility"; public const string RenderLod = "render.lod"; + public const string CargoQuantity = "inventory.cargo.quantity"; } public static class AetheriaRuntimeDaemonRenderShadowModes diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs index 3cf238caf..c7d618379 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs @@ -193,6 +193,7 @@ namespace GameCult.Aetheria.State.Verse { var entity = entities[index]; accessor.Write(layout.EntityIndex + index * IntStride, entity.EntityIndex); + accessor.Write(layout.CargoQuantity + index * IntStride, CountCargoUnits(entity)); WriteFloat3(accessor, layout.Position, index, entity.PositionX, entity.PositionY, entity.PositionZ); WriteFloat(accessor, layout.RotationRadians, index, Math.Atan2(entity.DirectionX, entity.DirectionY)); WriteFloat3(accessor, layout.Velocity, index, entity.VelocityX, 0.0, entity.VelocityY); @@ -218,6 +219,7 @@ namespace GameCult.Aetheria.State.Verse var pickup = pickups[pickupRow]; var row = rowOffset + pickupRow; accessor.Write(layout.EntityIndex + row * IntStride, firstPickupEntityIndex + pickup.PickupIndex); + accessor.Write(layout.CargoQuantity + row * IntStride, 0); WriteFloat3(accessor, layout.Position, row, pickup.PositionX, pickup.PositionY, pickup.PositionZ); WriteFloat(accessor, layout.RotationRadians, row, 0.0); WriteFloat3(accessor, layout.Velocity, row, pickup.VelocityX, pickup.VelocityY, pickup.VelocityZ); @@ -255,6 +257,15 @@ namespace GameCult.Aetheria.State.Verse return !double.IsNaN(value) && !double.IsInfinity(value); } + private static int CountCargoUnits(AetheriaRuntimeEntitySnapshotCommit entity) + { + return (entity.CargoContents ?? Array.Empty()) + .Where(bay => bay != null) + .SelectMany(bay => bay.Items ?? Array.Empty()) + .Where(slot => slot?.Item != null) + .Sum(slot => Math.Max(0, slot.Item.Quantity)); + } + private static RetainedMappedBuffer RetainBuffer(string location, long byteLength) { lock (Sync) @@ -329,6 +340,7 @@ namespace GameCult.Aetheria.State.Verse { private EntityHotSlabLayout( long entityIndex, + long cargoQuantity, long position, long rotationRadians, long velocity, @@ -342,6 +354,7 @@ namespace GameCult.Aetheria.State.Verse long totalByteLength) { EntityIndex = entityIndex; + CargoQuantity = cargoQuantity; Position = position; RotationRadians = rotationRadians; Velocity = velocity; @@ -356,6 +369,7 @@ namespace GameCult.Aetheria.State.Verse } public long EntityIndex { get; } + public long CargoQuantity { get; } public long Position { get; } public long RotationRadians { get; } public long Velocity { get; } @@ -373,6 +387,7 @@ namespace GameCult.Aetheria.State.Verse count = Math.Max(0, count); var offset = 0L; var entityIndex = Take(ref offset, count, IntStride); + var cargoQuantity = Take(ref offset, count, IntStride); var position = Take(ref offset, count, Float3Stride); var rotationRadians = Take(ref offset, count, FloatStride); var velocity = Take(ref offset, count, Float3Stride); @@ -386,6 +401,7 @@ namespace GameCult.Aetheria.State.Verse var renderGroupId = Take(ref offset, count, IntStride); return new EntityHotSlabLayout( entityIndex, + cargoQuantity, position, rotationRadians, velocity, @@ -404,6 +420,7 @@ namespace GameCult.Aetheria.State.Verse return new[] { Column("entity-index", AetheriaRuntimeDaemonSoaColumnKinds.EntityIndex, "int32", EntityIndex, IntStride, count, "index", "world"), + Column("cargo-quantity", AetheriaRuntimeDaemonSoaColumnKinds.CargoQuantity, "int32", CargoQuantity, IntStride, count, "items", "entity"), Column("position", AetheriaRuntimeDaemonSoaColumnKinds.Position, "float3", Position, Float3Stride, count, "world_units", "world"), Column("rotation-radians", AetheriaRuntimeDaemonSoaColumnKinds.RotationRadians, "float32", RotationRadians, FloatStride, count, "radians", "world"), Column("velocity", AetheriaRuntimeDaemonSoaColumnKinds.Velocity, "float3", Velocity, Float3Stride, count, "world_units_per_second", "world"), diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimePickupTransactions.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimePickupTransactions.cs index fa2b75be4..2e6b04576 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimePickupTransactions.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimePickupTransactions.cs @@ -8,7 +8,8 @@ namespace GameCult.Aetheria.State.Verse public static class AetheriaRuntimePickupTransactions { public static bool TryCollect(AetheriaRuntimeZoneSnapshotCommit zone, AetheriaRuntimeEntitySnapshotCommit entity, - int pickupIndex, AetheriaRuntimeCatalogSnapshot? catalog, bool requireRange = true) + int pickupIndex, AetheriaRuntimeCatalogSnapshot? catalog, bool requireRange = true, + double collectionRange = 25) { var pickups = (zone.DroppedPickups ?? Array.Empty()).ToList(); var index = pickups.FindIndex(pickup => pickup != null && pickup.PickupIndex == pickupIndex); @@ -16,7 +17,7 @@ namespace GameCult.Aetheria.State.Verse var pickup = pickups[index]; var quantity = Math.Max(1, pickup.Item?.Quantity ?? 1); if (pickup.AgeSeconds >= pickup.LifetimeSeconds || - (requireRange && Math.Pow(pickup.PositionX - entity.PositionX, 2) + Math.Pow(pickup.PositionZ - entity.PositionZ, 2) > 25 * 25) || + (requireRange && Math.Pow(pickup.PositionX - entity.PositionX, 2) + Math.Pow(pickup.PositionZ - entity.PositionZ, 2) > collectionRange * collectionRange) || quantity > AetheriaRuntimeCargoCapacityQueries.UnitsThatFit(entity, catalog, pickup.Item?.ItemKey ?? "")) return false; var bays = (entity.CargoContents ?? Array.Empty()).ToList(); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs index 9eb0e4a7b..8f347519f 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeSnapshotDocuments.cs @@ -588,6 +588,9 @@ namespace GameCult.Aetheria.State.Verse [Key(17)] public IReadOnlyList PhysicalPayloads { get; set; } = Array.Empty(); + + [Key(18)] + public int NextPickupIndex { get; set; } } [MessagePackObject] diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index a35fb411d..b67820dea 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -2166,9 +2166,15 @@ credit changes, cargo transfer, ship creation, and checkpoint. Runtime loadout restore follows the same rule: UI requests restoration, and the daemon owns instantiation, credits, dock assignment, current entity, and checkpoint. Docked current-ship selection follows the same rule: UI requests selection, and the -daemon owns `CurrentEntity`, `DockingBay.DockedShip`, and checkpoint. Loot -pickup follows the same rule: collision code reports the pickup opportunity, -and the daemon owns cargo storage and checkpoint. Entity destruction follows +daemon owns `CurrentEntity`, `DockingBay.DockedShip`, and checkpoint. Undocking +also owns a collision-free departure pose and clears inherited velocity before +the detached ship re-enters world physics. Loot pickup follows the same rule: +an active tractor inside its operating envelope requests collection, and the +daemon atomically owns capacity validation, cargo storage, pickup removal, +monotonic pickup identity, and checkpoint. Physics moves loose bodies but does +not decide inventory ownership. The portable Eve entity SoA publishes +`inventory.cargo.quantity`, allowing generic clients and witnesses to observe +the committed cargo delta without reading Aetheria internals. Entity destruction follows the same rule: instance code observes death, and the daemon owns drop decisions, zone removal, and checkpoint. Dropped world pickups are typed zone-snapshot state, not only