From 7c0c61c5c9e0c64f1240f62e5560494c51b0b0d2 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 13 Jul 2026 04:50:32 +0100 Subject: [PATCH] Project daemon pickups through the Eve world view --- .../AetheriaDaemonZoneGenerator.cs | 12 ++- .../Tests/DaemonRuntimeDocumentTests.cs | 36 +++++++- .../AetheriaRuntimeDaemonSoaFramePublisher.cs | 89 ++++++++++++++----- docs/original-game-migration-matrix.md | 4 +- 4 files changed, 114 insertions(+), 27 deletions(-) diff --git a/Aetheria.State.Daemon/AetheriaDaemonZoneGenerator.cs b/Aetheria.State.Daemon/AetheriaDaemonZoneGenerator.cs index a8bbcc580..9a780c48d 100644 --- a/Aetheria.State.Daemon/AetheriaDaemonZoneGenerator.cs +++ b/Aetheria.State.Daemon/AetheriaDaemonZoneGenerator.cs @@ -84,7 +84,17 @@ internal static class AetheriaDaemonZoneGenerator GravityTerrainDepth = -7, GravityTerrainDepthExponent = 1.18, GravityTerrainBoundaryFog = 0.25, - GravityTerrainWaveFrequency = 0.55 + GravityTerrainWaveFrequency = 0.55, + DroppedPickups = + [ + new AetheriaDroppedPickupSnapshot + { + PickupIndex = 0, + Position = Vec3(-15, 0, -5), + Velocity = Vec3(0, 0, 0), + Item = new AetheriaLoadoutItem { ItemKey = "scrap-metal", Quantity = 1 } + } + ] }).ConfigureAwait(false); for (var i = 0; i < entities.Length; i++) diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index c248526fb..02a090766 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -2523,7 +2523,7 @@ public class DaemonRuntimeDocumentTests { RunId = "run-soa-frame", CurrentZoneIndex = 2, - CurrentEntityKey = "entity:player", + CurrentEntityKey = "zone.2.entity.7", Zones = new[] { new AetheriaRuntimeZoneSnapshotCommit @@ -2553,7 +2553,15 @@ public class DaemonRuntimeDocumentTests DirectionY = 0, VelocityX = 5, VelocityY = 6, - IsActive = true + IsActive = true, + Contacts = new[] + { + new AetheriaRuntimeEntityContactCommit + { + TargetEntityIndex = 3, + Visible = true + } + } }, new AetheriaRuntimeEntitySnapshotCommit { @@ -2563,6 +2571,19 @@ public class DaemonRuntimeDocumentTests PositionZ = -8, IsActive = false } + }, + DroppedPickups = new[] + { + new AetheriaRuntimeDroppedPickupCommit + { + PickupIndex = 5, + PositionX = 20, + PositionY = 1, + PositionZ = 30, + VelocityX = 2, + VelocityZ = 4, + Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "salvage", Quantity = 1 } + } } } } @@ -2579,7 +2600,12 @@ public class DaemonRuntimeDocumentTests Assert.IsFalse(view.Buffers[0].ObserverWritable); Assert.AreEqual(11, view.Columns.Count); Assert.AreEqual(1, view.RenderGroups.Count); - Assert.AreEqual(2, view.RenderGroups[0].InstanceCount); + Assert.AreEqual(3, view.RenderGroups[0].InstanceCount); + Assert.IsTrue(view.Identities.Any(identity => + identity.EntityIndex == 13 && + identity.EntityId == "pickup:2:5" && + identity.Kind == "pickup" && + identity.AssetRef == "prefab.entity.pickup")); var index = AetheriaRuntimeDaemonSoaViewIndex.Build(view); Assert.IsTrue(index.IsValid, string.Join("\n", index.ValidationErrors)); @@ -2597,8 +2623,12 @@ public class DaemonRuntimeDocumentTests Assert.AreEqual(12f, accessor.ReadSingle(position.AbsoluteByteOffset + position.Column.ElementStride), 0.0001f); Assert.AreEqual(34f, accessor.ReadSingle(position.AbsoluteByteOffset + position.Column.ElementStride + 8), 0.0001f); Assert.AreEqual(6f, accessor.ReadSingle(velocity.AbsoluteByteOffset + velocity.Column.ElementStride + 8), 0.0001f); + Assert.AreEqual(13, accessor.ReadInt32(entityIndex.AbsoluteByteOffset + entityIndex.Column.ElementStride * 2)); + Assert.AreEqual(20f, accessor.ReadSingle(position.AbsoluteByteOffset + position.Column.ElementStride * 2), 0.0001f); + Assert.AreEqual(30f, accessor.ReadSingle(position.AbsoluteByteOffset + position.Column.ElementStride * 2 + 8), 0.0001f); Assert.AreEqual(0, accessor.ReadByte(visibility.AbsoluteByteOffset)); Assert.AreEqual(1, accessor.ReadByte(visibility.AbsoluteByteOffset + visibility.Column.ElementStride)); + Assert.AreEqual(1, accessor.ReadByte(visibility.AbsoluteByteOffset + visibility.Column.ElementStride * 2)); } [Test] diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs index ed315564f..565a6cfd0 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs @@ -57,13 +57,19 @@ namespace GameCult.Aetheria.State.Verse .Where(entity => entity != null && visibleEntityIndices.Contains(entity.EntityIndex)) .OrderBy(entity => entity.EntityIndex) .ToArray(); - var count = entities.Length; + var pickups = (zone?.DroppedPickups ?? Array.Empty()) + .Where(pickup => pickup != null) + .OrderBy(pickup => pickup.PickupIndex) + .ToArray(); + var firstPickupEntityIndex = entities.Length == 0 ? 0 : entities.Max(entity => entity.EntityIndex) + 1; + var count = entities.Length + pickups.Length; var generation = Math.Max(frame.FrameId, 0); var layout = EntityHotSlabLayout.Create(count); var location = CreateLocation(stateFilePath, frame.SessionId, generation); var buffer = RetainBuffer(location, layout.TotalByteLength); WriteEntities(buffer.Accessor, layout, entities); + WritePickups(buffer.Accessor, layout, pickups, entities.Length, firstPickupEntityIndex); var view = AetheriaRuntimeDaemonSoaViewDocument.Create( string.IsNullOrWhiteSpace(frame.DaemonId) ? "aetheria-daemon" : frame.DaemonId, @@ -89,34 +95,50 @@ namespace GameCult.Aetheria.State.Verse layout.CreateDirtyRanges(count, generation), backend: AetheriaRuntimeDaemonSoaBackends.MemoryMappedFile, synchronizationMode: AetheriaRuntimeDaemonSoaSynchronizationModes.ImmutableFrame, - renderGroups: CreateRenderGroups(entities), + renderGroups: CreateRenderGroups(entities, pickups), identities: entities.Select(entity => new AetheriaRuntimeDaemonSoaIdentityDocument - { - EntityIndex = entity.EntityIndex, - EntityId = entity.EntityId, - Kind = entity.Kind, - Label = entity.Name, - Faction = entity.FactionKey, - Selectable = entity.EntityIndex != controlled?.EntityIndex, - Controllable = entity.EntityIndex == controlled?.EntityIndex, - AssetRef = AetheriaRuntimeAssets.ResolveEntityPrefabAssetRef(entity) - }).ToArray()); + { + EntityIndex = entity.EntityIndex, + EntityId = entity.EntityId, + Kind = entity.Kind, + Label = entity.Name, + Faction = entity.FactionKey, + Selectable = entity.EntityIndex != controlled?.EntityIndex, + Controllable = entity.EntityIndex == controlled?.EntityIndex, + AssetRef = AetheriaRuntimeAssets.ResolveEntityPrefabAssetRef(entity) + }) + .Concat(pickups.Select(pickup => new AetheriaRuntimeDaemonSoaIdentityDocument + { + EntityIndex = firstPickupEntityIndex + pickup.PickupIndex, + EntityId = $"pickup:{run.CurrentZoneIndex}:{pickup.PickupIndex}", + Kind = "pickup", + Label = string.IsNullOrWhiteSpace(pickup.Item?.ItemKey) ? "Pickup" : pickup.Item.ItemKey, + Faction = "", + Selectable = true, + Controllable = false, + AssetRef = "prefab.entity.pickup" + })) + .ToArray()); return view; } private static IReadOnlyList CreateRenderGroups( - IReadOnlyList entities) + IReadOnlyList entities, + IReadOnlyList pickups) { - if (entities.Count == 0) + if (entities.Count == 0 && pickups.Count == 0) return Array.Empty(); - var minX = entities.Min(entity => (float)entity.PositionX); - var minY = entities.Min(entity => (float)entity.PositionY); - var minZ = entities.Min(entity => (float)entity.PositionZ); - var maxX = entities.Max(entity => (float)entity.PositionX); - var maxY = entities.Max(entity => (float)entity.PositionY); - var maxZ = entities.Max(entity => (float)entity.PositionZ); + var positions = entities.Select(entity => (entity.PositionX, entity.PositionY, entity.PositionZ)) + .Concat(pickups.Select(pickup => (pickup.PositionX, pickup.PositionY, pickup.PositionZ))) + .ToArray(); + var minX = positions.Min(position => (float)position.PositionX); + var minY = positions.Min(position => (float)position.PositionY); + var minZ = positions.Min(position => (float)position.PositionZ); + var maxX = positions.Max(position => (float)position.PositionX); + var maxY = positions.Max(position => (float)position.PositionY); + var maxZ = positions.Max(position => (float)position.PositionZ); const float padding = 16.0f; return new[] @@ -140,7 +162,7 @@ namespace GameCult.Aetheria.State.Verse Layer = 0, ShaderKey = "aetheria.daemon.entity-proxy", DisplayName = "Daemon current-zone entities", - InstanceCount = entities.Count, + InstanceCount = entities.Count + pickups.Count, BoundsCenterX = (minX + maxX) * 0.5f, BoundsCenterY = (minY + maxY) * 0.5f, BoundsCenterZ = (minZ + maxZ) * 0.5f, @@ -177,6 +199,31 @@ namespace GameCult.Aetheria.State.Verse } } + private static void WritePickups( + MemoryMappedViewAccessor accessor, + EntityHotSlabLayout layout, + IReadOnlyList pickups, + int rowOffset, + int firstPickupEntityIndex) + { + for (var pickupRow = 0; pickupRow < pickups.Count; pickupRow++) + { + var pickup = pickups[pickupRow]; + var row = rowOffset + pickupRow; + accessor.Write(layout.EntityIndex + row * IntStride, firstPickupEntityIndex + pickup.PickupIndex); + 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); + WriteFloat(accessor, layout.PhysicsBodyRadius, row, 0.5); + WriteFloat(accessor, layout.PhysicsBodyMass, row, 0.25); + WriteFloat(accessor, layout.PhysicsBodyInverseMass, row, 4.0); + WriteFloat(accessor, layout.RenderScale, row, 1.0); + accessor.Write(layout.RenderVisibility + row * ByteStride, (byte)1); + accessor.Write(layout.RenderLod + row * IntStride, 0); + accessor.Write(layout.RenderGroupId + row * IntStride, (uint)EntityRenderGroupId); + } + } + private static void WriteFloat(MemoryMappedViewAccessor accessor, long byteOffset, int index, double value) { accessor.Write(byteOffset + index * FloatStride, IsFinite(value) ? (float)value : 0.0f); diff --git a/docs/original-game-migration-matrix.md b/docs/original-game-migration-matrix.md index b0f9fbfe6..d96ee548d 100644 --- a/docs/original-game-migration-matrix.md +++ b/docs/original-game-migration-matrix.md @@ -26,7 +26,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity. | Thermal/energy | cell conduction, capacitor/reactor/radiator network, and cockpit thermal exposure | daemon | ship/equipment power, temperature, medical state, risk and death feedback | schematic/post effects | owner-exists; wired; exclusive; projected; generic timing and native asset delivery lowered: catalog hull and installed-item shapes derive cell mass/conductivity/topology; local temperature derives thermal performance, wear potential and online state; all consumers share capacitor-first/reactor-residual transactions; powered radiators pump before reactor settlement; reactor heat then enters the same cell network before conduction/radiation; cockpit-cell temperature drives the fossil nonlinear heatstroke/hypothermia accumulation, linear recovery, severe-risk crossings, and ordinary exactly-once destruction with a typed cause; Eve exposes cockpit, risk, heatstroke source-weight, phasing and death-transition facts; EveUnity generically resolves the original severe pulse plus live/reconnect-safe cause-specific death crossfade; Aetheria deterministically translates the five broken legacy profiles into clean URP profiles, advertises them by semantic role through CultMesh CDN, and binds them in the canonical client through a weight-only native sink; rotated equipment topology, parent/child radiation, schematic composition, legacy SSR/AO/roundness equivalents, canonical render-pipeline activation and rendered parity remain incomplete | multi-consumer ordering, multi-radiator visibility, rotated topology, generic schematic meters, renderer-feature parity, active URP capture and live/reconnect death-fade screenshots | | Weapons | ServerShared behaviors + Unity effects | daemon plus Ymir geometry/kinematics | action capability, weapon state, shot/damage receipts | effects/audio/HUD | instant and constant resource/timing lifecycles are daemon-owned; charged weapons accept one semantic request, spool without requiring a solution, hold at full charge, commit automatically when a solution appears, and perform deterministic once-per-second malfunction hazard checks after the authored safe hold interval with increasing persisted risk; generic Eve `weapon.state` exposes charge hold/risk and feedback exposes readiness, commit, refusal, and malfunction chronology; committed direct damage now enters the shared daemon armor-cell transaction | guided persistent payloads, visibility/wear, remaining impact-distribution parity, and Unity effect reconciliation | | Destruction/drops | hull death, 25% equipment rolls, unconditional cargo drops, 25-unit launch, 30-second pickups | daemon | destruction identity, death/drop events, typed pickups | provider-advertised destruction effect and pickups | owner-exists; wired; exclusive; projected: direct and deployable lethal damage commit one deterministic destruction transaction, clear live references, retain only a non-rendered identity tombstone, and emit exact pickups/events; the reserved client `DestroyEntity` command is rejected; Aetheria advertises its original big explosion as `effect.feedback.entity.destroyed`, lowered generically by EveUnity | equipment-destruction-before-hull parity and multiplayer reconnect chronology | -| Tractor/scoop | analog tractor and physical timed pickups | daemon + Ymir | tractor power, pickup body and receipt | beam/interaction feedback | fossil 2/s power ramp and authored forward radius/traction/distance feed pickup bodies into the shared Ymir world; shield contact collects exactly once when capacity permits or applies the fossil 25-unit rejection kick; 30s daemon lifetime; instant cargo teleport deleted | prove generic runtime beam, contact, success and rejection feedback | +| Tractor/scoop | analog tractor and physical timed pickups | daemon + Ymir | tractor power, pickup body and receipt | pickup world entity plus beam/interaction feedback | fossil 2/s power ramp and authored forward radius/traction/distance feed pickup bodies into the shared Ymir world; shield contact collects exactly once when capacity permits or applies the fossil 25-unit rejection kick; 30s daemon lifetime; instant cargo teleport deleted; current-zone pickups now occupy ordinary rows in the shared Eve entity SoA body with stable logical pickup identity and the provider-owned pickup asset; the generic Unity witness sees a paused deterministic salvage pickup, flies through it, and observes daemon/Ymir removal | add generic tractor beam plus rejected-capacity feedback and cargo-delta assertion | | Dock/undock | wormhole-first interact; first eligible bay; component prerequisites | daemon + Ymir placement | dock commands/context | camera/UI transition | daemon path wired/projected; Ymir placement and parity unproven | priority, eligibility, placement and reconnect | | Inventory/equipment | inventory panels + ServerShared | daemon | inventory/equipment surfaces | generic UI | owner-exists; wired/projected in fragments; not proven | all transfer directions and rejection | | Trade | trade UI/economy | daemon | stock, quote, purchase commands | generic UI | purchase owner wired/projected; not proven | atomic purchase and capacity | @@ -39,7 +39,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity. | Hit/lock/warnings | `ActionGameManager` feedback | daemon event facts | transient feedback stream | VFX/UI/audio | bounded deduplicated game-event ledger and Eve `feedback.stream` wired for pickup outcomes, projectile launch/impact, entity damage, alive-to-dead destruction, authoritative weapon reload chronology, and episode-deduplicated `weapon.fire.refused` facts for insufficient energy or missing ammunition; refusal identity, authored weapon, target, reason, and remaining magazine state are runtime-independent cockpit inputs | add lock transitions, thermal and docking event families, negative transaction fixtures, and runtime effect consumption | | Assets | `Assets/Resources` | Aetheria provider | asset catalog + CultMesh CDN | runtime cache/load | wired; basic lowering; not live-proven remotely | cold/warm remote-only live load and cache proof | | Save/resume | original persistence paths | daemon/CultCache | published current state | clients rehydrate | owner-exists; not parity-proven | mid-loop restart | -| Terminus loop | original game composition | daemon/Ymir/Eve | pilot surface | Aetheria.Unity | incomplete; no scenario proof | fly/fire/loot/dock/trade | +| Terminus loop | original game composition | daemon/Ymir/Eve | pilot surface | Aetheria.Unity | partial live scenario proof: generic Unity discovers the provider, lowers the pilot world and assets, flies through Ymir, sees and collects daemon-authored salvage, pauses, queues targeting/fire, resumes, and presents the authoritative shot and receipts | destruction-created loot, dock, and trade remain before the minimum loop is proven | | Starbridge | original/shared architecture intent | one daemon session | pilot + commander surfaces | Unity + Electron | commander task board and autonomous explore execution wired; Electron Eve lowering and split-target proof missing | commander orders plus four pilots and autonomous workers | | Behavior engine | `ServerShared/Behaviors` composition | daemon | executable action/status projection | action bar and feedback | tick reconciles equipped catalog payloads into persistent behavior state; shared evaluated-stat query proven; execution families remain partial | every behavior family, ordering, resource transaction and modifier lifecycle | | Sensors/visibility | decaying sources and observer information thresholds | daemon | contacts and ping events | indicators/maps | reference | threshold, decay, ping and classification timelines |