Publish Aetheria worlds through Eve entity SoA

This commit is contained in:
Meta Vens 2026-07-12 11:55:01 +01:00
commit 0bf28b48df
9 changed files with 146 additions and 36 deletions

View file

@ -1338,12 +1338,18 @@ static async Task PublishDaemonApiDocumentsAsync(
await node.MutableDocument<AetheriaRuntimeDaemonFrameDocument>(AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest)
.ReplaceAsync(result.Frame)
.ConfigureAwait(false);
await node.MutableDocument<AetheriaRuntimeZoneRenderDocument>(AetheriaRuntimeVerseRecordKeys.ZoneRenderLatest)
.ReplaceAsync(AetheriaRuntimeGameDocuments.ZoneRender(result.Frame))
.ConfigureAwait(false);
if (result.SoaView != null &&
string.Equals(result.SoaView.Schema, AetheriaRuntimeDaemonSchemas.SoaView, StringComparison.Ordinal))
{
await node.MutableDocument<AetheriaRuntimeDaemonSoaViewDocument>(AetheriaRuntimeVerseRecordKeys.DaemonSoaViewLatest)
.ReplaceAsync(result.SoaView)
.ConfigureAwait(false);
await node.MutableDocument<EveEntitySoaViewDocument>(AetheriaRuntimeVerseRecordKeys.EveEntitySoaViewLatest)
.ReplaceAsync(AetheriaRuntimeEveEntitySoaProjection.Project(result.SoaView))
.ConfigureAwait(false);
}
if (result.ProviderAdvertisement != null)

View file

@ -8,7 +8,7 @@
"com.unity.render-pipelines.universal": "17.4.0",
"org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-source-v1.0.3-r2",
"org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.1.1",
"org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.1.0",
"org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#ebed4096de399bcd82c3b5d5b93482ed1142f2cc"
"org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#413989371efe0180789603076711ea0ba8925dc5",
"org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#413989371efe0180789603076711ea0ba8925dc5"
}
}

View file

@ -11,6 +11,7 @@ using System.IO.MemoryMappedFiles;
using System.Linq;
using UnityEngine;
using EveCommandTemplate = GameCult.Eve.Surface.EveCommandTemplate;
using EveEntitySoaViewDocument = GameCult.Eve.Surface.EveEntitySoaViewDocument;
using EveStyleToken = GameCult.Eve.Surface.EveStyleToken;
using EveSurfaceCommandRequest = GameCult.Eve.Surface.EveSurfaceCommandRequest;
using EveSurfaceComponent = GameCult.Eve.Surface.EveSurfaceComponent;
@ -484,6 +485,32 @@ public class DaemonRuntimeDocumentTests
Assert.AreEqual(0, tracker.Reconcile(new[] { fact }, 11).Count);
}
[Test]
public void EveWorldSurfacePointsToPortableEntitySoaInsteadOfEmbeddingEntities()
{
var run = RunWithTwoEntities();
var frame = AetheriaRuntimeDaemonFrameDocument.Create(
run, "test-daemon", "session", 42, 1.0, 0.02);
var surface = AetheriaRuntimeDaemonGameSurfaceBuilder.Build(
frame,
new AetheriaRuntimeDaemonHealthDocument(),
AetheriaRuntimeDaemonCommandBoundaryDocument.Create("test-daemon"));
var source = AetheriaRuntimeDaemonSoaViewDocument.Create(
"test-daemon", "session", 42, 42,
new[] { new AetheriaRuntimeDaemonSoaBufferDocument { BufferId = "hot", Location = "mmf:test" } },
new[] { new AetheriaRuntimeDaemonSoaColumnDocument { ColumnId = "position", Kind = AetheriaRuntimeDaemonSoaColumnKinds.Position, BufferId = "hot", ScalarType = "float32", ElementStride = 12, ElementCount = 2 } });
var portable = AetheriaRuntimeEveEntitySoaProjection.Project(source);
Assert.IsTrue(ContainsSurfaceProp(surface.Surface.Root, "entityViewPointerId",
AetheriaRuntimeVerseRecordKeys.EveEntitySoaViewLatest.ToString()));
Assert.IsTrue(ContainsSurfaceProp(surface.Surface.Root, "entityViewSchema",
EveEntitySoaViewDocument.SchemaId));
Assert.IsFalse(ContainsSurfaceKind(surface.Surface.Root, "world.entity3d"));
Assert.AreEqual(EveEntitySoaViewDocument.SchemaId, portable.Schema);
Assert.AreEqual(42, portable.Generation);
Assert.AreEqual(AetheriaRuntimeDaemonSoaColumnKinds.Position, portable.Columns.Single().Semantic);
}
[Test]
public void TickRunnerAppliesObservedCommandsAndPublishesFrame()
{
@ -5490,6 +5517,12 @@ public class DaemonRuntimeDocumentTests
return component.Children.Any(child => ContainsSurfaceProp(child, key, value));
}
private static bool ContainsSurfaceKind(AetheriaRuntimeSurfaceComponent component, string kind)
{
return string.Equals(component.Kind, kind, StringComparison.Ordinal) ||
component.Children.Any(child => ContainsSurfaceKind(child, kind));
}
private static bool ContainsSurfaceStateBinding(
AetheriaRuntimeSurfaceComponent component,
string targetProp,

View file

@ -22,9 +22,9 @@
"org.gamecult.aetheria.state": "file:org.gamecult.aetheria.state",
"org.gamecult.cultmath": "file:../../CultMath",
"org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-source-v1.0.3-r2",
"org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.1.0",
"org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#413989371efe0180789603076711ea0ba8925dc5",
"org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.1.1",
"org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.1.4",
"org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#413989371efe0180789603076711ea0ba8925dc5",
"org.gamecult.eve.unity-uitoolkit": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.0",
"com.unity.modules.accessibility": "1.0.0",
"com.unity.modules.adaptiveperformance": "1.0.0",

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using GameCult.Eve.Surface;
#nullable enable
@ -390,6 +391,10 @@ namespace GameCult.Aetheria.State.Verse
{
["label"] = string.IsNullOrWhiteSpace(zone.Name) ? "Starbridge" : zone.Name,
["statePointerId"] = AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString(),
["entityViewPointerId"] = AetheriaRuntimeVerseRecordKeys.EveEntitySoaViewLatest.ToString(),
["entityViewSchema"] = EveEntitySoaViewDocument.SchemaId,
["zoneRenderPointerId"] = AetheriaRuntimeVerseRecordKeys.ZoneRenderLatest.ToString(),
["zoneRenderSchema"] = AetheriaRuntimeDaemonSchemas.ZoneRender,
["assetManifest"] = AetheriaRuntimeVerseRecordKeys.EveAssetCatalog.ToString(),
["inputCapability"] = AetheriaRuntimeVerseRecordKeys.PilotInputCapability.ToString(),
["inputProfile"] = "rts.pointer-keyboard.v1",
@ -397,20 +402,11 @@ namespace GameCult.Aetheria.State.Verse
["zoneIndex"] = zone.ZoneIndex.ToString(CultureInfo.InvariantCulture),
["runId"] = run.RunId ?? ""
};
var entities = (zone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
.Where(entity => entity != null && entity.IsActive)
.Select(entity => PlayableWorldEntity(
entity,
run,
zone,
run.CurrentEntityKey,
AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault))
.ToArray();
return new AetheriaRuntimeSurfaceComponent(
id,
"world.scene2d",
props,
entities,
Array.Empty<AetheriaRuntimeSurfaceComponent>(),
AetheriaRuntimeSurfaceStateBindings.FromProps(props),
Array.Empty<AetheriaRuntimeEmbeddedDocumentSlot>(),
Layout(("position", "absolute"), ("inset", "0"), ("width", "100%"), ("height", "100%")),
@ -575,6 +571,10 @@ namespace GameCult.Aetheria.State.Verse
{
["label"] = string.IsNullOrWhiteSpace(zone.Name) ? "Aetheria World" : zone.Name,
["statePointerId"] = AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString(),
["entityViewPointerId"] = AetheriaRuntimeVerseRecordKeys.EveEntitySoaViewLatest.ToString(),
["entityViewSchema"] = EveEntitySoaViewDocument.SchemaId,
["zoneRenderPointerId"] = AetheriaRuntimeVerseRecordKeys.ZoneRenderLatest.ToString(),
["zoneRenderSchema"] = AetheriaRuntimeDaemonSchemas.ZoneRender,
["assetManifest"] = AetheriaRuntimeVerseRecordKeys.EveAssetCatalog.ToString(),
["inputProfile"] = "arpg.pointer-keyboard.v1",
["cameraRig"] = "arpg.orbital-follow.v1",
@ -591,27 +591,11 @@ namespace GameCult.Aetheria.State.Verse
["runId"] = run.RunId ?? ""
};
var entities = (zone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
.Where(candidate => candidate != null && candidate.IsActive)
.Select(candidate => PlayableWorldEntity(
candidate,
run,
zone,
currentEntityKey,
simulationSettings))
.Concat((zone.PhysicalPayloads ?? Array.Empty<AetheriaRuntimePhysicalPayloadCommit>())
.Where(projectile => projectile != null && projectile.LifetimeSeconds > 0)
.Select(projectile => PlayableWorldProjectile(projectile, run, zone)))
.Concat((zone.DroppedPickups ?? Array.Empty<AetheriaRuntimeDroppedPickupCommit>())
.Where(pickup => pickup != null && pickup.AgeSeconds < pickup.LifetimeSeconds)
.Select(pickup => PlayableWorldPickup(pickup, run, zone)))
.ToArray();
return new AetheriaRuntimeSurfaceComponent(
id,
"world.scene3d",
props,
entities,
Array.Empty<AetheriaRuntimeSurfaceComponent>(),
AetheriaRuntimeSurfaceStateBindings.FromProps(props),
Array.Empty<AetheriaRuntimeEmbeddedDocumentSlot>(),
Layout(

View file

@ -0,0 +1,77 @@
using System;
using System.Linq;
using GameCult.Eve.Surface;
#nullable enable
namespace GameCult.Aetheria.State.Verse
{
public static class AetheriaRuntimeEveEntitySoaProjection
{
public static EveEntitySoaViewDocument Project(AetheriaRuntimeDaemonSoaViewDocument source)
{
if (source == null) throw new ArgumentNullException(nameof(source));
return new EveEntitySoaViewDocument
{
ProviderId = "aetheria.daemon",
ViewId = "pilot",
FrameId = source.FrameId,
Generation = source.Generation,
PublishedAtUtc = source.PublishedAtUtc,
Backend = source.Backend,
SynchronizationMode = source.SynchronizationMode,
Buffers = (source.Buffers ?? Array.Empty<AetheriaRuntimeDaemonSoaBufferDocument>())
.Select(buffer => new EveEntitySoaBuffer
{
BufferId = buffer.BufferId,
Backend = buffer.Backend,
Location = buffer.Location,
ByteOffset = buffer.ByteOffset,
ByteLength = buffer.ByteLength,
Generation = buffer.Generation
}).ToArray(),
Columns = (source.Columns ?? Array.Empty<AetheriaRuntimeDaemonSoaColumnDocument>())
.Select(column => new EveEntitySoaColumn
{
ColumnId = column.ColumnId,
Semantic = column.Kind,
BufferId = column.BufferId,
ScalarType = column.ScalarType,
ByteOffset = column.ByteOffset,
ElementStride = column.ElementStride,
ElementCount = column.ElementCount,
Unit = column.Unit,
CoordinateSpace = column.CoordinateSpace
}).ToArray(),
DirtyRanges = (source.DirtyRanges ?? Array.Empty<AetheriaRuntimeDaemonSoaDirtyRangeDocument>())
.Select(range => new EveEntitySoaDirtyRange
{
ColumnId = range.ColumnId,
StartIndex = range.StartIndex,
Count = range.Count,
Generation = range.Generation
}).ToArray(),
RenderGroups = (source.RenderGroups ?? Array.Empty<AetheriaRuntimeDaemonRenderGroupDocument>())
.Select(group => new EveEntityRenderGroup
{
GroupId = group.GroupId,
MeshAssetRef = group.MeshAsset.Uri,
MaterialAssetRef = group.MaterialAsset.Uri,
SubMeshIndex = group.SubMeshIndex,
Layer = group.Layer,
InstanceCount = Math.Max(group.InstanceCount, 0),
DefaultScale = group.DefaultScale,
BoundsCenterX = group.BoundsCenterX,
BoundsCenterY = group.BoundsCenterY,
BoundsCenterZ = group.BoundsCenterZ,
BoundsSizeX = Math.Max(group.BoundsSizeX, 0),
BoundsSizeY = Math.Max(group.BoundsSizeY, 0),
BoundsSizeZ = Math.Max(group.BoundsSizeZ, 0),
ShadowMode = group.ShadowMode,
ReceiveShadows = group.ReceiveShadows,
Lod = group.Lod
}).ToArray()
};
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6a9f9d5385753c848b28b1add6461006

View file

@ -50,6 +50,12 @@ namespace GameCult.Aetheria.State.Verse
public static CultRecordKey DaemonSoaViewLatest { get; } =
new CultRecordKey("daemon:aetheria.soa_view.latest.v1");
public static CultRecordKey EveEntitySoaViewLatest { get; } =
new CultRecordKey("eve:entity-view:aetheria.daemon.pilot");
public static CultRecordKey ZoneRenderLatest { get; } =
new CultRecordKey("daemon:aetheria.zone_render.latest.v1");
public static CultRecordKey StarbridgeScenarioLatest { get; } =
new CultRecordKey("starbridge:aetheria.scenario.latest.v1");
@ -178,6 +184,7 @@ namespace GameCult.Aetheria.State.Verse
typeof(EveSurfaceCommandRequest),
typeof(EveCommandReceiptDocument),
typeof(EveAssetCatalogDocument),
typeof(EveEntitySoaViewDocument),
typeof(AetheriaRuntimeDaemonCommandDocument),
typeof(AetheriaRuntimeEveCommandDocument),
typeof(AetheriaRuntimeCommittedCommandFactDocument)

View file

@ -331,24 +331,25 @@
"hash": "0b099274a4e2b4c301eced4322166837792f585a"
},
"org.gamecult.eve.surface": {
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.1.0",
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#413989371efe0180789603076711ea0ba8925dc5",
"depth": 0,
"source": "git",
"dependencies": {
"org.gamecult.cultlib": "1.0.3"
},
"hash": "e10821f1cc81f619479c6507438f6a097d1f0ce2"
"hash": "413989371efe0180789603076711ea0ba8925dc5"
},
"org.gamecult.eve.unity-scene": {
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.1.4",
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#413989371efe0180789603076711ea0ba8925dc5",
"depth": 0,
"source": "git",
"dependencies": {
"org.gamecult.cultlib": "1.0.3",
"org.gamecult.eve.plugin-fields": "0.1.1",
"org.gamecult.eve.surface": "0.1.0"
"org.gamecult.eve.surface": "0.1.0",
"com.unity.mathematics": "1.3.2"
},
"hash": "093eb80d6c2a6da216b9e6b3fb921494e427102c"
"hash": "413989371efe0180789603076711ea0ba8925dc5"
},
"org.gamecult.eve.unity-uitoolkit": {
"version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-uitoolkit#eveunity-uitoolkit-v0.1.0",