diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 03084d91d..7d0b9101c 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -7396,6 +7396,7 @@ static void RequireDaemonVersePublication(string root) var daemonTickRunnerPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonTickRunner.cs"); var daemonPublicationStorePath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonPublicationStore.cs"); var daemonSoaDocumentsPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonSoaDocuments.cs"); + var daemonSoaFramePublisherPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonSoaFramePublisher.cs"); var daemonStateRefsPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonStateRefs.cs"); var daemonGameSurfaceBuilderPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonGameSurfaceBuilder.cs"); var daemonEditorSurfaceBuilderPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonEditorSurfaceBuilder.cs"); @@ -7418,6 +7419,7 @@ static void RequireDaemonVersePublication(string root) daemonTickRunnerPath, daemonPublicationStorePath, daemonSoaDocumentsPath, + daemonSoaFramePublisherPath, daemonStateRefsPath, daemonGameSurfaceBuilderPath, daemonEditorSurfaceBuilderPath, @@ -7449,6 +7451,7 @@ static void RequireDaemonVersePublication(string root) var daemonTickRunner = File.ReadAllText(daemonTickRunnerPath); var daemonPublicationStore = File.ReadAllText(daemonPublicationStorePath); var daemonSoaDocuments = File.ReadAllText(daemonSoaDocumentsPath); + var daemonSoaFramePublisher = File.ReadAllText(daemonSoaFramePublisherPath); var daemonStateRefs = File.ReadAllText(daemonStateRefsPath); var daemonGameSurfaceBuilder = File.ReadAllText(daemonGameSurfaceBuilderPath); var daemonEditorSurfaceBuilder = File.ReadAllText(daemonEditorSurfaceBuilderPath); @@ -7503,6 +7506,33 @@ static void RequireDaemonVersePublication(string root) throw new InvalidOperationException("Daemon SoA view is no longer a registered CultCache/CultNet document."); } + var requiredSoaFramePublisherSymbols = new[] + { + "public static class AetheriaRuntimeDaemonSoaFramePublisher", + "PublishCurrentZoneEntities(", + "AetheriaRuntimeDaemonSoaBackends.MemoryMappedFile", + "MemoryMappedFile.CreateOrOpen(", + "ObserverWritable = false", + "AetheriaRuntimeDaemonSoaColumnKinds.PositionX", + "AetheriaRuntimeDaemonSoaColumnKinds.PositionY", + "AetheriaRuntimeDaemonSoaColumnKinds.PositionZ", + "AetheriaRuntimeDaemonSoaColumnKinds.VelocityX", + "AetheriaRuntimeDaemonSoaColumnKinds.VelocityZ", + "AetheriaRuntimeDaemonSoaColumnKinds.PhysicsBodyRadius", + "AetheriaRuntimeDaemonSoaColumnKinds.RenderVisibility", + "AetheriaRuntimeDaemonSoaColumnKinds.RenderGroupId", + "AetheriaRuntimeDaemonSoaViewStore.PublishView(stateFilePath, view)" + }; + var missingSoaFramePublisherSymbols = requiredSoaFramePublisherSymbols + .Where(symbol => !daemonSoaFramePublisher.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingSoaFramePublisherSymbols.Length > 0) + { + throw new InvalidOperationException( + "Daemon SoA frame publisher no longer turns authoritative frames into observer-readable direct-memory slabs: " + + string.Join(", ", missingSoaFramePublisherSymbols)); + } + var requiredBoundarySymbols = new[] { "RuntimeDaemonProviderFileSuffix", @@ -7709,6 +7739,7 @@ static void RequireDaemonVersePublication(string root) "VerseId", "CultMeshAddress", "AetheriaRuntimeDaemonCommandBoundaryDocument.Create", + "AetheriaRuntimeDaemonSoaFramePublisher.PublishCurrentZoneEntities(stateFilePath, frame)", "AetheriaRuntimeDaemonProviderAdvertisementDocument.Create", "AetheriaRuntimeDaemonPublicationStore.PublishCommandBoundary", "AetheriaRuntimeDaemonPublicationStore.PublishProviderAdvertisement", diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index 420167e9b..5656c567f 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using System; using System.Collections.Generic; using System.IO; +using System.IO.MemoryMappedFiles; using System.Linq; public class DaemonRuntimeDocumentTests @@ -1651,6 +1652,94 @@ public class DaemonRuntimeDocumentTests Assert.AreEqual(256, stored.DirtyRanges[0].Count); } + [Test] + public void SoaFramePublisherPublishesMappableCurrentZoneEntitySlab() + { + var statePath = Path.Combine( + Path.GetTempPath(), + "aetheria-daemon-soa-frame-publisher-tests", + Path.GetRandomFileName(), + "state.cc"); + var frame = AetheriaRuntimeDaemonFrameDocument.Create( + new AetheriaRuntimeRunCheckpointCommit + { + RunId = "run-soa-frame", + CurrentZoneIndex = 2, + CurrentEntityKey = "entity:player", + Zones = new[] + { + new AetheriaRuntimeZoneSnapshotCommit + { + ZoneIndex = 1, + Entities = new[] + { + new AetheriaRuntimeEntitySnapshotCommit + { + EntityIndex = 99, + PositionX = 999 + } + } + }, + new AetheriaRuntimeZoneSnapshotCommit + { + ZoneIndex = 2, + Entities = new[] + { + new AetheriaRuntimeEntitySnapshotCommit + { + EntityIndex = 7, + PositionX = 12, + PositionY = 3, + PositionZ = 34, + DirectionX = 1, + DirectionY = 0, + VelocityX = 5, + VelocityY = 6, + IsActive = true + }, + new AetheriaRuntimeEntitySnapshotCommit + { + EntityIndex = 3, + PositionX = -2, + PositionY = 4, + PositionZ = -8, + IsActive = false + } + } + } + } + }, + "aetheria-daemon", + "session-soa-frame", + 44, + 1.0, + 0.02); + + var view = AetheriaRuntimeDaemonSoaFramePublisher.PublishCurrentZoneEntities(statePath, frame); + Assert.IsTrue(AetheriaRuntimeDaemonSoaViewStore.TryReadView(statePath, out var stored)); + Assert.AreEqual(view.Generation, stored.Generation); + Assert.AreEqual(AetheriaRuntimeDaemonSoaBackends.MemoryMappedFile, stored.Backend); + Assert.AreEqual(1, stored.Buffers.Count); + Assert.IsFalse(stored.Buffers[0].ObserverWritable); + Assert.AreEqual(14, stored.Columns.Count); + Assert.AreEqual(1, stored.RenderGroups.Count); + Assert.AreEqual(2, stored.RenderGroups[0].InstanceCount); + + var index = AetheriaRuntimeDaemonSoaViewIndex.Build(stored); + Assert.IsTrue(index.IsValid, string.Join("\n", index.ValidationErrors)); + Assert.IsTrue(index.TryGetFirstColumnOfKind(AetheriaRuntimeDaemonSoaColumnKinds.PositionX, out var positionX)); + Assert.IsTrue(index.TryGetFirstColumnOfKind(AetheriaRuntimeDaemonSoaColumnKinds.VelocityZ, out var velocityZ)); + Assert.IsTrue(index.TryGetFirstColumnOfKind(AetheriaRuntimeDaemonSoaColumnKinds.RenderVisibility, out var visibility)); + + using var memory = MemoryMappedFile.OpenExisting(stored.Buffers[0].Location, MemoryMappedFileRights.Read); + using var accessor = memory.CreateViewAccessor(0, stored.Buffers[0].ByteLength, MemoryMappedFileAccess.Read); + Assert.AreEqual(-2f, accessor.ReadSingle(positionX.AbsoluteByteOffset), 0.0001f); + Assert.AreEqual(12f, accessor.ReadSingle(positionX.AbsoluteByteOffset + positionX.Column.ElementStride), 0.0001f); + Assert.AreEqual(6f, accessor.ReadSingle(velocityZ.AbsoluteByteOffset + velocityZ.Column.ElementStride), 0.0001f); + Assert.AreEqual(0, accessor.ReadByte(visibility.AbsoluteByteOffset)); + Assert.AreEqual(1, accessor.ReadByte(visibility.AbsoluteByteOffset + visibility.Column.ElementStride)); + } + [Test] public void SoaViewStoreReportsMissingView() { diff --git a/GameCult.Aetheria.State.Unity.csproj b/GameCult.Aetheria.State.Unity.csproj index 03bea47e5..14b7275ba 100644 --- a/GameCult.Aetheria.State.Unity.csproj +++ b/GameCult.Aetheria.State.Unity.csproj @@ -92,6 +92,7 @@ + diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs new file mode 100644 index 000000000..7f3596129 --- /dev/null +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs @@ -0,0 +1,369 @@ +using System; +using System.Collections.Generic; +using System.IO.MemoryMappedFiles; +using System.Linq; +using System.Security.Cryptography; +using System.Text; + +#nullable enable + +namespace GameCult.Aetheria.State.Verse +{ + public static class AetheriaRuntimeDaemonSoaFramePublisher + { + private const string BufferId = "current-zone-entities-hot"; + private const int EntityRenderGroupId = 1; + private const int FloatStride = 4; + private const int IntStride = 4; + private const int ByteStride = 1; + private const int RetainedBufferCount = 4; + + private static readonly object Sync = new object(); + private static readonly Dictionary RetainedBuffers = + new Dictionary(StringComparer.Ordinal); + + public static AetheriaRuntimeDaemonSoaViewDocument PublishCurrentZoneEntities( + string stateFilePath, + AetheriaRuntimeDaemonFrameDocument frame) + { + if (string.IsNullOrWhiteSpace(stateFilePath)) + throw new ArgumentException("State file path must be non-empty.", nameof(stateFilePath)); + if (frame == null) + throw new ArgumentNullException(nameof(frame)); + + var run = frame.Run ?? new AetheriaRuntimeRunCheckpointCommit(); + var zone = (run.Zones ?? Array.Empty()) + .FirstOrDefault(candidate => candidate != null && candidate.ZoneIndex == run.CurrentZoneIndex); + var entities = (zone?.Entities ?? Array.Empty()) + .Where(entity => entity != null) + .OrderBy(entity => entity.EntityIndex) + .ToArray(); + var count = entities.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); + + var view = AetheriaRuntimeDaemonSoaViewDocument.Create( + string.IsNullOrWhiteSpace(frame.DaemonId) ? "aetheria-daemon" : frame.DaemonId, + string.IsNullOrWhiteSpace(frame.SessionId) ? "local" : frame.SessionId, + frame.FrameId, + generation, + new[] + { + new AetheriaRuntimeDaemonSoaBufferDocument + { + BufferId = BufferId, + DisplayName = "Current zone daemon entity hot slab", + Backend = AetheriaRuntimeDaemonSoaBackends.MemoryMappedFile, + Location = location, + ByteOffset = 0, + ByteLength = layout.TotalByteLength, + Generation = generation, + DaemonWritable = true, + ObserverWritable = false + } + }, + layout.CreateColumns(count), + layout.CreateDirtyRanges(count, generation), + backend: AetheriaRuntimeDaemonSoaBackends.MemoryMappedFile, + synchronizationMode: AetheriaRuntimeDaemonSoaSynchronizationModes.ImmutableFrame, + renderGroups: CreateRenderGroups(entities)); + + AetheriaRuntimeDaemonSoaViewStore.PublishView(stateFilePath, view); + return view; + } + + private static IReadOnlyList CreateRenderGroups( + IReadOnlyList entities) + { + if (entities.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); + const float padding = 16.0f; + + return new[] + { + new AetheriaRuntimeDaemonRenderGroupDocument + { + GroupId = EntityRenderGroupId, + MeshKey = "resources://Aetheria/Daemon/EntityProxy", + MaterialKey = "resources://Aetheria/Daemon/EntityProxy", + SubMeshIndex = 0, + Layer = 0, + ShaderKey = "aetheria.daemon.entity-proxy", + DisplayName = "Daemon current-zone entities", + InstanceCount = entities.Count, + BoundsCenterX = (minX + maxX) * 0.5f, + BoundsCenterY = (minY + maxY) * 0.5f, + BoundsCenterZ = (minZ + maxZ) * 0.5f, + BoundsSizeX = Math.Max(maxX - minX + padding, padding), + BoundsSizeY = Math.Max(maxY - minY + padding, padding), + BoundsSizeZ = Math.Max(maxZ - minZ + padding, padding), + ShadowMode = AetheriaRuntimeDaemonRenderShadowModes.On, + ReceiveShadows = true, + DefaultScale = 1.0f, + Lod = -1 + } + }; + } + + private static void WriteEntities( + MemoryMappedViewAccessor accessor, + EntityHotSlabLayout layout, + IReadOnlyList entities) + { + for (var index = 0; index < entities.Count; index++) + { + var entity = entities[index]; + WriteFloat(accessor, layout.PositionX, index, entity.PositionX); + WriteFloat(accessor, layout.PositionY, index, entity.PositionY); + WriteFloat(accessor, layout.PositionZ, index, entity.PositionZ); + WriteFloat(accessor, layout.RotationRadians, index, Math.Atan2(entity.DirectionX, entity.DirectionY)); + WriteFloat(accessor, layout.VelocityX, index, entity.VelocityX); + WriteFloat(accessor, layout.VelocityY, index, 0.0); + WriteFloat(accessor, layout.VelocityZ, index, entity.VelocityY); + WriteFloat(accessor, layout.PhysicsBodyRadius, index, 1.0); + WriteFloat(accessor, layout.PhysicsBodyMass, index, 1.0); + WriteFloat(accessor, layout.PhysicsBodyInverseMass, index, 1.0); + WriteFloat(accessor, layout.RenderScale, index, 1.0); + accessor.Write(layout.RenderVisibility + index * ByteStride, (byte)(entity.IsActive ? 1 : 0)); + accessor.Write(layout.RenderLod + index * IntStride, 0); + accessor.Write(layout.RenderGroupId + index * 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); + } + + private static bool IsFinite(double value) + { + return !double.IsNaN(value) && !double.IsInfinity(value); + } + + private static RetainedMappedBuffer RetainBuffer(string location, long byteLength) + { + lock (Sync) + { + if (RetainedBuffers.TryGetValue(location, out var existing)) + return existing; + + var memory = MemoryMappedFile.CreateOrOpen(location, byteLength, MemoryMappedFileAccess.ReadWrite); + var accessor = memory.CreateViewAccessor(0, byteLength, MemoryMappedFileAccess.ReadWrite); + var buffer = new RetainedMappedBuffer(memory, accessor); + RetainedBuffers[location] = buffer; + TrimRetainedBuffers(); + return buffer; + } + } + + private static void TrimRetainedBuffers() + { + if (RetainedBuffers.Count <= RetainedBufferCount) + return; + + foreach (var key in RetainedBuffers.Keys.OrderBy(key => key).Take(RetainedBuffers.Count - RetainedBufferCount).ToArray()) + { + RetainedBuffers[key].Dispose(); + RetainedBuffers.Remove(key); + } + } + + private static string CreateLocation(string stateFilePath, string sessionId, long generation) + { + using var sha = SHA256.Create(); + var identity = $"{stateFilePath}|{sessionId}|{generation}"; + var hash = sha.ComputeHash(Encoding.UTF8.GetBytes(identity)); + return "Aetheria.Daemon.Soa." + BitConverter.ToString(hash, 0, 12).Replace("-", ""); + } + + private sealed class RetainedMappedBuffer : IDisposable + { + private readonly MemoryMappedFile _memory; + public RetainedMappedBuffer(MemoryMappedFile memory, MemoryMappedViewAccessor accessor) + { + _memory = memory; + Accessor = accessor; + } + + public MemoryMappedViewAccessor Accessor { get; } + + public void Dispose() + { + Accessor.Dispose(); + _memory.Dispose(); + } + } + + private readonly struct EntityHotSlabLayout + { + private EntityHotSlabLayout( + long positionX, + long positionY, + long positionZ, + long rotationRadians, + long velocityX, + long velocityY, + long velocityZ, + long physicsBodyRadius, + long physicsBodyMass, + long physicsBodyInverseMass, + long renderScale, + long renderVisibility, + long renderLod, + long renderGroupId, + long totalByteLength) + { + PositionX = positionX; + PositionY = positionY; + PositionZ = positionZ; + RotationRadians = rotationRadians; + VelocityX = velocityX; + VelocityY = velocityY; + VelocityZ = velocityZ; + PhysicsBodyRadius = physicsBodyRadius; + PhysicsBodyMass = physicsBodyMass; + PhysicsBodyInverseMass = physicsBodyInverseMass; + RenderScale = renderScale; + RenderVisibility = renderVisibility; + RenderLod = renderLod; + RenderGroupId = renderGroupId; + TotalByteLength = totalByteLength; + } + + public long PositionX { get; } + public long PositionY { get; } + public long PositionZ { get; } + public long RotationRadians { get; } + public long VelocityX { get; } + public long VelocityY { get; } + public long VelocityZ { get; } + public long PhysicsBodyRadius { get; } + public long PhysicsBodyMass { get; } + public long PhysicsBodyInverseMass { get; } + public long RenderScale { get; } + public long RenderVisibility { get; } + public long RenderLod { get; } + public long RenderGroupId { get; } + public long TotalByteLength { get; } + + public static EntityHotSlabLayout Create(int count) + { + count = Math.Max(0, count); + var offset = 0L; + var positionX = Take(ref offset, count, FloatStride); + var positionY = Take(ref offset, count, FloatStride); + var positionZ = Take(ref offset, count, FloatStride); + var rotationRadians = Take(ref offset, count, FloatStride); + var velocityX = Take(ref offset, count, FloatStride); + var velocityY = Take(ref offset, count, FloatStride); + var velocityZ = Take(ref offset, count, FloatStride); + var physicsBodyRadius = Take(ref offset, count, FloatStride); + var physicsBodyMass = Take(ref offset, count, FloatStride); + var physicsBodyInverseMass = Take(ref offset, count, FloatStride); + var renderScale = Take(ref offset, count, FloatStride); + var renderVisibility = Take(ref offset, count, ByteStride); + offset = Align4(offset); + var renderLod = Take(ref offset, count, IntStride); + var renderGroupId = Take(ref offset, count, IntStride); + return new EntityHotSlabLayout( + positionX, + positionY, + positionZ, + rotationRadians, + velocityX, + velocityY, + velocityZ, + physicsBodyRadius, + physicsBodyMass, + physicsBodyInverseMass, + renderScale, + renderVisibility, + renderLod, + renderGroupId, + Math.Max(1, offset)); + } + + public AetheriaRuntimeDaemonSoaColumnDocument[] CreateColumns(int count) + { + return new[] + { + Column("position-x", AetheriaRuntimeDaemonSoaColumnKinds.PositionX, "float32", PositionX, FloatStride, count, "world_units", "world"), + Column("position-y", AetheriaRuntimeDaemonSoaColumnKinds.PositionY, "float32", PositionY, FloatStride, count, "world_units", "world"), + Column("position-z", AetheriaRuntimeDaemonSoaColumnKinds.PositionZ, "float32", PositionZ, FloatStride, count, "world_units", "world"), + Column("rotation-radians", AetheriaRuntimeDaemonSoaColumnKinds.RotationRadians, "float32", RotationRadians, FloatStride, count, "radians", "world"), + Column("velocity-x", AetheriaRuntimeDaemonSoaColumnKinds.VelocityX, "float32", VelocityX, FloatStride, count, "world_units_per_second", "world"), + Column("velocity-y", AetheriaRuntimeDaemonSoaColumnKinds.VelocityY, "float32", VelocityY, FloatStride, count, "world_units_per_second", "world"), + Column("velocity-z", AetheriaRuntimeDaemonSoaColumnKinds.VelocityZ, "float32", VelocityZ, FloatStride, count, "world_units_per_second", "world"), + Column("physics-body-radius", AetheriaRuntimeDaemonSoaColumnKinds.PhysicsBodyRadius, "float32", PhysicsBodyRadius, FloatStride, count, "world_units", "world"), + Column("physics-body-mass", AetheriaRuntimeDaemonSoaColumnKinds.PhysicsBodyMass, "float32", PhysicsBodyMass, FloatStride, count, "mass_units", "world"), + Column("physics-body-inverse-mass", AetheriaRuntimeDaemonSoaColumnKinds.PhysicsBodyInverseMass, "float32", PhysicsBodyInverseMass, FloatStride, count, "inverse_mass_units", "world"), + Column("render-scale", AetheriaRuntimeDaemonSoaColumnKinds.RenderScale, "float32", RenderScale, FloatStride, count, "scale", "world"), + Column("render-visibility", AetheriaRuntimeDaemonSoaColumnKinds.RenderVisibility, "uint8", RenderVisibility, ByteStride, count, "bool", "world"), + Column("render-lod", AetheriaRuntimeDaemonSoaColumnKinds.RenderLod, "int32", RenderLod, IntStride, count, "lod", "world"), + Column("render-group-id", AetheriaRuntimeDaemonSoaColumnKinds.RenderGroupId, "uint32", RenderGroupId, IntStride, count, "id", "world") + }; + } + + public AetheriaRuntimeDaemonSoaDirtyRangeDocument[] CreateDirtyRanges(int count, long generation) + { + return CreateColumns(count) + .Select(column => new AetheriaRuntimeDaemonSoaDirtyRangeDocument + { + ColumnId = column.ColumnId, + StartIndex = 0, + Count = count, + Generation = generation + }) + .ToArray(); + } + + private static AetheriaRuntimeDaemonSoaColumnDocument Column( + string columnId, + string kind, + string scalarType, + long byteOffset, + int stride, + int count, + string unit, + string coordinateSpace) + { + return new AetheriaRuntimeDaemonSoaColumnDocument + { + ColumnId = columnId, + Kind = kind, + BufferId = BufferId, + ScalarType = scalarType, + ByteOffset = byteOffset, + ElementStride = stride, + ElementCount = count, + Unit = unit, + CoordinateSpace = coordinateSpace + }; + } + + private static long Take(ref long offset, int count, int stride) + { + var current = offset; + offset += (long)count * stride; + return current; + } + + private static long Align4(long value) + { + var remainder = value % 4; + return remainder == 0 ? value : value + 4 - remainder; + } + } + } +} diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs.meta b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs.meta new file mode 100644 index 000000000..639d53ef0 --- /dev/null +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSoaFramePublisher.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 9fbb9a6fd4f941148b655e587104ec2b diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonTickRunner.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonTickRunner.cs index 229b1f9f1..57a611f0c 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonTickRunner.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonTickRunner.cs @@ -126,6 +126,7 @@ namespace GameCult.Aetheria.State.Verse }; var framePath = AetheriaRuntimeDaemonFrameStore.PublishFrame(stateFilePath, frame); + AetheriaRuntimeDaemonSoaFramePublisher.PublishCurrentZoneEntities(stateFilePath, frame); var commandBoundary = AetheriaRuntimeDaemonCommandBoundaryDocument.Create(options.DaemonId); var commandBoundaryPath = AetheriaRuntimeDaemonPublicationStore.PublishCommandBoundary( stateFilePath,