Integrate Aetheria reactive state worktree

This commit is contained in:
Meta Vens 2026-06-28 01:18:21 +01:00
commit 65133ac8a0
61 changed files with 3427 additions and 402 deletions

View file

@ -197,6 +197,23 @@ namespace GameCult.Aetheria.State.Verse
return AetheriaRuntimeRtsProjection.ProjectGravityViewport(frame, viewport);
}
public async Task<AetheriaRuntimeRenderSplatsViewportDocument> RenderSplatsViewportAsync(
AetheriaRuntimeRtsViewportBounds viewport)
{
ThrowIfDisposed();
var frame = await RequireFrameAsync().ConfigureAwait(false);
return AetheriaRuntimeRtsProjection.ProjectRenderSplatsViewport(frame, viewport);
}
public async Task<AetheriaRuntimeAssetManifestDocument> AssetManifestAsync()
{
ThrowIfDisposed();
var frame = await RequireFrameAsync().ConfigureAwait(false);
return AetheriaRuntimeAssets.ProjectManifest(
_verse.OpenRuntimeCatalog(),
frame.Run?.RunId ?? "");
}
public async Task<AetheriaRuntimeCurrentZoneDocument> CurrentZoneAsync()
{
ThrowIfDisposed();
@ -254,7 +271,11 @@ namespace GameCult.Aetheria.State.Verse
var frame = await RequireFrameAsync().ConfigureAwait(false);
scenario ??= await _verse.GetStarbridgeScenarioAsync().ConfigureAwait(false);
session ??= await _verse.GetStarbridgeSessionAsync().ConfigureAwait(false);
return AetheriaRuntimeStarbridgeProjection.ProjectSessionSummary(frame, scenario, session);
return AetheriaRuntimeStarbridgeProjection.ProjectSessionSummary(
frame,
scenario,
session,
_verse.OpenRuntimeCatalog());
}
public async Task<AetheriaRuntimeSelectedObjectDocument> SelectedObjectAsync(int entityIndex)

View file

@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using GameCult.Caching;
using MessagePack;
#nullable enable
namespace GameCult.Aetheria.State.Verse
{
public static class AetheriaRuntimeAssetKinds
{
public const string Texture = "texture";
public const string Sprite = "sprite";
public const string Mesh = "mesh";
public const string Material = "material";
public const string Shader = "shader";
public const string Audio = "audio";
public const string Prefab = "prefab";
}
public static class AetheriaRuntimeAssetTransports
{
public const string CultMesh = "cultmesh";
public const string Resources = "resources";
public const string UnityAddressable = "unity_addressable";
}
[MessagePackObject]
public sealed class AetheriaRuntimeAssetRef
{
[Key(0)]
public string AssetKey { get; set; } = "";
[Key(1)]
public string Kind { get; set; } = "";
[Key(2)]
public string Uri { get; set; } = "";
[Key(3)]
public string Transport { get; set; } = AetheriaRuntimeAssetTransports.CultMesh;
[Key(4)]
public string ContentHash { get; set; } = "";
[Key(5)]
public string MimeType { get; set; } = "";
[Key(6)]
public IReadOnlyDictionary<string, string> Metadata { get; set; } =
new Dictionary<string, string>();
public static AetheriaRuntimeAssetRef Empty(string kind = "")
{
return new AetheriaRuntimeAssetRef { Kind = kind ?? "" };
}
public static AetheriaRuntimeAssetRef FromKey(
string key,
string kind,
string? uri = null,
string transport = AetheriaRuntimeAssetTransports.CultMesh,
string? mimeType = null)
{
key ??= "";
return new AetheriaRuntimeAssetRef
{
AssetKey = key,
Kind = kind ?? "",
Uri = string.IsNullOrWhiteSpace(uri) ? key : uri ?? "",
Transport = string.IsNullOrWhiteSpace(transport)
? AetheriaRuntimeAssetTransports.CultMesh
: transport,
MimeType = mimeType ?? ""
};
}
}
[CultDocument("gamecult.aetheria.asset_manifest", "gamecult.aetheria.asset_manifest.v1")]
[MessagePackObject]
public sealed class AetheriaRuntimeAssetManifestDocument
{
[Key(0)]
public string Schema { get; set; } = AetheriaRuntimeDaemonSchemas.AssetManifest;
[Key(1)]
public string PublishedAtUtc { get; set; } = "";
[Key(2)]
public string RunId { get; set; } = "";
[Key(3)]
public string BaseUri { get; set; } = "cultmesh://aetheria.local/assets";
[Key(4)]
public IReadOnlyList<AetheriaRuntimeAssetManifestEntry> Assets { get; set; } =
Array.Empty<AetheriaRuntimeAssetManifestEntry>();
}
[MessagePackObject]
public sealed class AetheriaRuntimeAssetManifestEntry
{
[Key(0)]
public AetheriaRuntimeAssetRef Ref { get; set; } = new AetheriaRuntimeAssetRef();
[Key(1)]
public long SizeBytes { get; set; } = -1;
[Key(2)]
public int Width { get; set; }
[Key(3)]
public int Height { get; set; }
[Key(4)]
public IReadOnlyList<string> Tags { get; set; } = Array.Empty<string>();
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9ff95c77b30d4b8c8d2df0f2a4de0ef8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,134 @@
using System;
using System.Collections.Generic;
using System.Linq;
#nullable enable
namespace GameCult.Aetheria.State.Verse
{
public static class AetheriaRuntimeAssets
{
public static AetheriaRuntimeAssetManifestDocument ProjectManifest(
AetheriaRuntimeCatalogSnapshot? catalog,
string runId = "",
string baseUri = "cultmesh://aetheria.local/assets")
{
var entries = new Dictionary<string, AetheriaRuntimeAssetManifestEntry>(StringComparer.Ordinal);
Add(entries, MapIcon("entity.player", "Player", "Sprites/Map/player"));
Add(entries, MapIcon("entity.ship", "Ship", "Sprites/Map/ship"));
Add(entries, MapIcon("entity.orbital", "Orbital", "Sprites/Map/orbital"));
Add(entries, MapIcon("entity.station", "Station", "Sprites/Map/station"));
Add(entries, MapIcon("body.planet", "Planet", "Sprites/Map/planet"));
Add(entries, MapIcon("body.sun", "Sun", "Sprites/Map/sun"));
Add(entries, MapIcon("body.asteroid", "Asteroid", "Sprites/Map/asteroid"));
foreach (var item in catalog?.Items ?? Array.Empty<AetheriaRuntimeCatalogItem>())
{
if (item == null || string.IsNullOrWhiteSpace(item.ItemKey))
continue;
var icon = AssetRefFromCatalogIcon(item.ActionBarIcon, $"item.{item.ItemKey}.icon");
if (!string.IsNullOrWhiteSpace(icon.AssetKey))
{
Add(entries, new AetheriaRuntimeAssetManifestEntry
{
Ref = icon,
Tags = new[] { "item", item.ItemKey, item.Category ?? "" }
.Where(tag => !string.IsNullOrWhiteSpace(tag))
.ToArray()
});
}
}
return new AetheriaRuntimeAssetManifestDocument
{
PublishedAtUtc = DateTime.UtcNow.ToString("O"),
RunId = runId ?? "",
BaseUri = string.IsNullOrWhiteSpace(baseUri) ? "cultmesh://aetheria.local/assets" : baseUri,
Assets = entries.Values
.OrderBy(entry => entry.Ref.AssetKey, StringComparer.Ordinal)
.ToArray()
};
}
public static AetheriaRuntimeAssetRef ResolveEntityIcon(AetheriaRuntimeRtsViewportObject? obj)
{
if (obj?.Controlled == true)
return Sprite("map.entity.player", "Sprites/Map/player");
var kind = (obj?.Kind ?? "").Trim().ToLowerInvariant();
if (kind.IndexOf("station", StringComparison.Ordinal) >= 0)
return Sprite("map.entity.station", "Sprites/Map/station");
if (kind.IndexOf("orbital", StringComparison.Ordinal) >= 0)
return Sprite("map.entity.orbital", "Sprites/Map/orbital");
return Sprite("map.entity.ship", "Sprites/Map/ship");
}
public static AetheriaRuntimeAssetRef AssetRefFromCatalogIcon(
string? catalogPath,
string fallbackAssetKey)
{
if (string.IsNullOrWhiteSpace(catalogPath))
return AetheriaRuntimeAssetRef.Empty(AetheriaRuntimeAssetKinds.Texture);
var resourcePath = NormalizeResourcePath(catalogPath ?? "");
var assetKey = string.IsNullOrWhiteSpace(fallbackAssetKey)
? $"catalog.{resourcePath}".Replace('/', '.').Replace('\\', '.')
: fallbackAssetKey;
return AetheriaRuntimeAssetRef.FromKey(
assetKey,
AetheriaRuntimeAssetKinds.Texture,
$"resources://{resourcePath}",
AetheriaRuntimeAssetTransports.Resources,
"image/*");
}
private static AetheriaRuntimeAssetManifestEntry MapIcon(
string key,
string label,
string resourcePath)
{
return new AetheriaRuntimeAssetManifestEntry
{
Ref = Sprite($"map.{key}", resourcePath),
Tags = new[] { "map", "icon", label }
};
}
private static AetheriaRuntimeAssetRef Sprite(string key, string resourcePath)
{
return AetheriaRuntimeAssetRef.FromKey(
key,
AetheriaRuntimeAssetKinds.Sprite,
$"resources://{NormalizeResourcePath(resourcePath)}",
AetheriaRuntimeAssetTransports.Resources,
"image/*");
}
private static string NormalizeResourcePath(string path)
{
path ??= "";
const string resourcesPrefix = "Assets/Resources/";
if (path.StartsWith(resourcesPrefix, StringComparison.OrdinalIgnoreCase))
path = path.Substring(resourcesPrefix.Length);
var extensionIndex = path.LastIndexOf('.');
if (extensionIndex > 0)
path = path.Substring(0, extensionIndex);
return path.Replace('\\', '/').Trim('/');
}
private static void Add(
Dictionary<string, AetheriaRuntimeAssetManifestEntry> entries,
AetheriaRuntimeAssetManifestEntry entry)
{
var key = entry.Ref?.AssetKey ?? "";
if (key.Length == 0)
return;
entries[key] = entry;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8e38efc9379f4a7ea4b5df5ca079b5c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -111,6 +111,7 @@ namespace GameCult.Aetheria.State.Verse
AccountedCommandIds = currentFrame.AccountedCommandIds,
CumulativeAppliedCommandIds = currentFrame.CumulativeAppliedCommandIds,
CumulativeRejectedCommandIds = currentFrame.CumulativeRejectedCommandIds,
Catalog = AetheriaRuntimeCatalogStore.OpenReadOnly(stateFilePath),
PublishWitnesses = false
});

View file

@ -83,6 +83,24 @@ namespace GameCult.Aetheria.State.Verse
CultMesh.ReadSingleFileDocumentPayload(path, AetheriaRuntimeDaemonSchemas.SoaView));
}
public static void WriteAssetManifest(string path, AetheriaRuntimeAssetManifestDocument document)
{
WriteDocument(
path,
$"latest:gamecult.aetheria.asset_manifest.{document.RunId}.v1",
AetheriaRuntimeDaemonSchemas.AssetManifest,
"gamecult.aetheria.asset_manifest",
"gamecult.aetheria.asset_manifest.v1",
document.PublishedAtUtc,
MessagePackSerializer.Serialize(document));
}
public static AetheriaRuntimeAssetManifestDocument ReadAssetManifest(string path)
{
return MessagePackSerializer.Deserialize<AetheriaRuntimeAssetManifestDocument>(
CultMesh.ReadSingleFileDocumentPayload(path, AetheriaRuntimeDaemonSchemas.AssetManifest));
}
public static void WriteDaemonProviderAdvertisement(
string path,
AetheriaRuntimeDaemonProviderAdvertisementDocument document)

View file

@ -65,6 +65,8 @@ namespace GameCult.Aetheria.State.Verse
public const string RtsViewport = "gamecult.aetheria.rts_viewport.v1";
public const string ObjectsViewport = "gamecult.aetheria.objects_viewport.v1";
public const string GravityViewport = "gamecult.aetheria.gravity_viewport.v1";
public const string RenderSplatsViewport = "gamecult.aetheria.render_splats_viewport.v1";
public const string AssetManifest = "gamecult.aetheria.asset_manifest.v1";
public const string CurrentZone = "gamecult.aetheria.current_zone.v1";
public const string CurrentEntity = "gamecult.aetheria.current_entity.v1";
public const string CurrentDocking = "gamecult.aetheria.current_docking.v1";
@ -258,6 +260,9 @@ namespace GameCult.Aetheria.State.Verse
[Key(20)]
public string CultMeshAddress { get; set; } = "cultmesh://aetheria.local/eve/providers/aetheria.daemon";
[Key(21)]
public string AssetManifestWitnessPath { get; set; } = "";
public static AetheriaRuntimeDaemonProviderAdvertisementDocument Create(
string stateFilePath,
string daemonId,
@ -273,6 +278,7 @@ namespace GameCult.Aetheria.State.Verse
FrameWitnessPath = AetheriaRuntimeStateBoundary.GetDaemonFramePath(stateFilePath ?? ""),
SoaWitnessPath = AetheriaRuntimeStateBoundary.GetDaemonSoaViewPath(stateFilePath ?? ""),
HealthWitnessPath = AetheriaRuntimeStateBoundary.GetDaemonHealthPath(stateFilePath ?? ""),
AssetManifestWitnessPath = AetheriaRuntimeStateBoundary.GetDaemonAssetManifestPath(stateFilePath ?? ""),
CommandBoundaryWitnessPath = AetheriaRuntimeStateBoundary.GetDaemonCommandBoundaryPath(stateFilePath ?? ""),
EveGuiSurfaceWitnessPath = AetheriaRuntimeStateBoundary.GetDaemonGameSurfacePath(stateFilePath ?? ""),
EveTuiSurfaceWitnessPath = AetheriaRuntimeStateBoundary.GetDaemonGameTuiSurfacePath(stateFilePath ?? ""),
@ -293,6 +299,8 @@ namespace GameCult.Aetheria.State.Verse
AetheriaRuntimeDaemonSchemas.CommandBoundary,
AetheriaRuntimeDaemonSchemas.ObjectsViewport,
AetheriaRuntimeDaemonSchemas.GravityViewport,
AetheriaRuntimeDaemonSchemas.RenderSplatsViewport,
AetheriaRuntimeDaemonSchemas.AssetManifest,
AetheriaRuntimeDaemonSchemas.CurrentZone,
AetheriaRuntimeDaemonSchemas.CurrentEntity,
AetheriaRuntimeDaemonSchemas.CurrentDocking,

View file

@ -27,6 +27,11 @@ namespace GameCult.Aetheria.State.Verse
return AetheriaRuntimeStateBoundary.GetDaemonCommandBoundaryPath(stateFilePath);
}
public static string GetAssetManifestPath(string stateFilePath)
{
return AetheriaRuntimeStateBoundary.GetDaemonAssetManifestPath(stateFilePath);
}
public static string GetStarbridgeSessionSummaryPath(string stateFilePath)
{
return AetheriaRuntimeStateBoundary.GetDaemonStarbridgeSessionSummaryPath(stateFilePath);
@ -114,6 +119,22 @@ namespace GameCult.Aetheria.State.Verse
return path;
}
public static string PublishAssetManifest(
string stateFilePath,
AetheriaRuntimeAssetManifestDocument document)
{
if (document == null) throw new ArgumentNullException(nameof(document));
document.Schema = AetheriaRuntimeDaemonSchemas.AssetManifest;
if (string.IsNullOrWhiteSpace(document.PublishedAtUtc))
document.PublishedAtUtc = DateTime.UtcNow.ToString("O");
var path = GetAssetManifestPath(stateFilePath);
Directory.CreateDirectory(Path.GetDirectoryName(path) ?? ".");
AetheriaRuntimeCultCacheDocumentStore.WriteAssetManifest(path, document);
return path;
}
public static string PublishStarbridgeSessionSummary(
string stateFilePath,
AetheriaRuntimeStarbridgeSessionSummaryDocument document)
@ -228,6 +249,21 @@ namespace GameCult.Aetheria.State.Verse
return true;
}
public static bool TryReadAssetManifest(
string stateFilePath,
out AetheriaRuntimeAssetManifestDocument document)
{
var path = GetAssetManifestPath(stateFilePath);
if (!File.Exists(path))
{
document = new AetheriaRuntimeAssetManifestDocument();
return false;
}
document = AetheriaRuntimeCultCacheDocumentStore.ReadAssetManifest(path);
return true;
}
public static bool TryReadStarbridgeSessionSummary(
string stateFilePath,
out AetheriaRuntimeStarbridgeSessionSummaryDocument document)

View file

@ -186,6 +186,14 @@ namespace GameCult.Aetheria.State.Verse
[Key(17)]
public int Lod { get; set; } = -1;
[Key(18)]
public AetheriaRuntimeAssetRef MeshAsset { get; set; } =
AetheriaRuntimeAssetRef.Empty(AetheriaRuntimeAssetKinds.Mesh);
[Key(19)]
public AetheriaRuntimeAssetRef MaterialAsset { get; set; } =
AetheriaRuntimeAssetRef.Empty(AetheriaRuntimeAssetKinds.Material);
}
[MessagePackObject]

View file

@ -99,6 +99,16 @@ namespace GameCult.Aetheria.State.Verse
GroupId = EntityRenderGroupId,
MeshKey = "resources://Aetheria/Daemon/EntityProxy",
MaterialKey = "resources://Aetheria/Daemon/EntityProxy",
MeshAsset = AetheriaRuntimeAssetRef.FromKey(
"daemon.entity_proxy.mesh",
AetheriaRuntimeAssetKinds.Mesh,
"resources://Aetheria/Daemon/EntityProxy",
AetheriaRuntimeAssetTransports.Resources),
MaterialAsset = AetheriaRuntimeAssetRef.FromKey(
"daemon.entity_proxy.material",
AetheriaRuntimeAssetKinds.Material,
"resources://Aetheria/Daemon/EntityProxy",
AetheriaRuntimeAssetTransports.Resources),
SubMeshIndex = 0,
Layer = 0,
ShaderKey = "aetheria.daemon.entity-proxy",

View file

@ -29,6 +29,7 @@ namespace GameCult.Aetheria.State.Verse
new AetheriaRuntimeDaemonOperationContext();
public AetheriaRuntimeStarbridgeScenarioDocument? StarbridgeScenario { get; set; }
public AetheriaRuntimeStarbridgeSessionDocument? StarbridgeSession { get; set; }
public AetheriaRuntimeCatalogSnapshot? Catalog { get; set; }
public bool PublishWitnesses { get; set; } = true;
}
@ -156,6 +157,7 @@ namespace GameCult.Aetheria.State.Verse
"aetheria.daemon.operation_execute.v1",
"aetheria.daemon.intent_state.v1",
"aetheria.daemon.authoritative_frame.v1",
AetheriaRuntimeDaemonSchemas.AssetManifest,
AetheriaRuntimeDaemonSchemas.ProviderAdvertisement,
AetheriaRuntimeDaemonSchemas.Health,
AetheriaRuntimeDaemonSchemas.CommandBoundary,
@ -212,10 +214,17 @@ namespace GameCult.Aetheria.State.Verse
CommandBoundaryPath = commandBoundaryPath
});
AetheriaRuntimeDaemonPublicationStore.TryReadHealth(stateFilePath, out var health);
AetheriaRuntimeDaemonPublicationStore.PublishAssetManifest(
stateFilePath,
AetheriaRuntimeAssets.ProjectManifest(
options.Catalog,
frame.Run?.RunId ?? "",
$"cultmesh://{options.VerseId}/assets"));
var starbridgeSummary = AetheriaRuntimeStarbridgeProjection.ProjectSessionSummary(
frame,
options.StarbridgeScenario,
options.StarbridgeSession);
options.StarbridgeSession,
options.Catalog);
AetheriaRuntimeDaemonPublicationStore.PublishStarbridgeSessionSummary(
stateFilePath,
starbridgeSummary);

View file

@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using GameCult.Caching;
using MessagePack;
#nullable enable
namespace GameCult.Aetheria.State.Verse
{
public static class AetheriaRuntimeRenderSplatChannels
{
public const int Visibility = 0;
public const int Gravity = 1;
public const int GravityWave = 2;
public const int Influence = 3;
public const int Tint = 4;
}
public static class AetheriaRuntimeRenderSplatLayerKeys
{
public const string GravityHeight = "gravity.height";
public const string GravityWave = "gravity.wave";
public const string Visibility = "visibility.mask";
public const string FogSurfaceHeight = "fog.surface_height";
public const string FogPatchHeight = "fog.patch_height";
public const string FogPatch = "fog.patch";
public const string FogTint = "fog.tint";
public const string Influence = "influence.mask";
}
public static class AetheriaRuntimeRenderSplatBlendModes
{
public const string Add = "add";
public const string Max = "max";
public const string Alpha = "alpha";
}
public static class AetheriaRuntimeRenderSplatSourceKinds
{
public const int Constant = 0;
public const int SimplexNoise = 1;
public const int AnimatedSimplexNoise = 2;
}
public static class AetheriaRuntimeRenderSplatFalloffs
{
public const int Solid = 0;
public const int Linear = 1;
public const int Smooth = 2;
public const int InverseSmooth = 3;
}
[CultDocument("gamecult.aetheria.render_splats_viewport", "gamecult.aetheria.render_splats_viewport.v1")]
[MessagePackObject]
public sealed class AetheriaRuntimeRenderSplatsViewportDocument
{
[Key(0)]
public string Schema { get; set; } = AetheriaRuntimeDaemonSchemas.RenderSplatsViewport;
[Key(1)]
public long FrameId { get; set; }
[Key(2)]
public string PublishedAtUtc { get; set; } = "";
[Key(3)]
public double SimulationTimeSeconds { get; set; }
[Key(4)]
public string RunId { get; set; } = "";
[Key(5)]
public int ZoneIndex { get; set; }
[Key(6)]
public string ZoneName { get; set; } = "";
[Key(7)]
public AetheriaRuntimeRtsViewportBounds Viewport { get; set; } = new AetheriaRuntimeRtsViewportBounds();
[Key(8)]
public IReadOnlyList<AetheriaRuntimeRenderSplatLayerDefinition> Layers { get; set; } =
Array.Empty<AetheriaRuntimeRenderSplatLayerDefinition>();
[Key(9)]
public AetheriaRuntimeRenderSplatSoa Splats { get; set; } = new AetheriaRuntimeRenderSplatSoa();
}
[MessagePackObject]
public sealed class AetheriaRuntimeRenderSplatLayerDefinition
{
[Key(0)]
public string LayerKey { get; set; } = "";
[Key(1)]
public string DisplayName { get; set; } = "";
[Key(2)]
public int Channel { get; set; }
[Key(3)]
public string BlendMode { get; set; } = AetheriaRuntimeRenderSplatBlendModes.Add;
[Key(4)]
public string GraphicsFormat { get; set; } = "R16_SFloat";
[Key(5)]
public bool ClearBeforeDraw { get; set; } = true;
[Key(6)]
public double ClearR { get; set; }
[Key(7)]
public double ClearG { get; set; }
[Key(8)]
public double ClearB { get; set; }
[Key(9)]
public double ClearA { get; set; }
}
[MessagePackObject]
public sealed class AetheriaRuntimeRenderSplatSoa
{
[Key(0)]
public int Count { get; set; }
[Key(1)]
public IReadOnlyList<double> CenterX { get; set; } = Array.Empty<double>();
[Key(2)]
public IReadOnlyList<double> CenterY { get; set; } = Array.Empty<double>();
[Key(3)]
public IReadOnlyList<double> HalfExtentX { get; set; } = Array.Empty<double>();
[Key(4)]
public IReadOnlyList<double> HalfExtentY { get; set; } = Array.Empty<double>();
[Key(5)]
public IReadOnlyList<double> RotationCos { get; set; } = Array.Empty<double>();
[Key(6)]
public IReadOnlyList<double> RotationSin { get; set; } = Array.Empty<double>();
[Key(7)]
public IReadOnlyList<int> Channel { get; set; } = Array.Empty<int>();
[Key(8)]
public IReadOnlyList<int> Falloff { get; set; } = Array.Empty<int>();
[Key(9)]
public IReadOnlyList<double> ValueR { get; set; } = Array.Empty<double>();
[Key(10)]
public IReadOnlyList<double> ValueG { get; set; } = Array.Empty<double>();
[Key(11)]
public IReadOnlyList<double> ValueB { get; set; } = Array.Empty<double>();
[Key(12)]
public IReadOnlyList<double> ValueA { get; set; } = Array.Empty<double>();
[Key(13)]
public IReadOnlyList<string> SourceKey { get; set; } = Array.Empty<string>();
[Key(14)]
public IReadOnlyList<int> LayerIndex { get; set; } = Array.Empty<int>();
[Key(15)]
public IReadOnlyList<int> SourceKind { get; set; } = Array.Empty<int>();
[Key(16)]
public IReadOnlyList<double> FrequencyX { get; set; } = Array.Empty<double>();
[Key(17)]
public IReadOnlyList<double> FrequencyY { get; set; } = Array.Empty<double>();
[Key(18)]
public IReadOnlyList<double> PhaseX { get; set; } = Array.Empty<double>();
[Key(19)]
public IReadOnlyList<double> PhaseY { get; set; } = Array.Empty<double>();
[Key(20)]
public IReadOnlyList<double> AnimationSpeed { get; set; } = Array.Empty<double>();
[Key(21)]
public IReadOnlyList<double> SourceFlags { get; set; } = Array.Empty<double>();
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5d69b2814aaf449fa925fd2f158ee9b7

View file

@ -107,6 +107,273 @@ namespace GameCult.Aetheria.State.Verse
};
}
public static AetheriaRuntimeRenderSplatsViewportDocument ProjectRenderSplatsViewport(
AetheriaRuntimeDaemonFrameDocument frame,
AetheriaRuntimeRtsViewportBounds viewport)
{
frame ??= new AetheriaRuntimeDaemonFrameDocument();
viewport ??= new AetheriaRuntimeRtsViewportBounds();
var normalizedViewport = Normalize(viewport);
var context = Context(frame);
var zone = context.Zone;
var layers = BuildDefaultRenderSplatLayers();
var layerIndices = layers
.Select((layer, index) => (layer.LayerKey, index))
.ToDictionary(pair => pair.LayerKey, pair => pair.index, StringComparer.Ordinal);
var splats = new RenderSplatBuilder();
var viewportCenterX = (normalizedViewport.MinX + normalizedViewport.MaxX) * 0.5;
var viewportCenterY = (normalizedViewport.MinY + normalizedViewport.MaxY) * 0.5;
var viewportHalfX = Math.Max(0.0001, (normalizedViewport.MaxX - normalizedViewport.MinX) * 0.5);
var viewportHalfY = Math.Max(0.0001, (normalizedViewport.MaxY - normalizedViewport.MinY) * 0.5);
if (zone.GravityTerrainDepth != 0)
{
splats.Add(
layerIndices[AetheriaRuntimeRenderSplatLayerKeys.GravityHeight],
viewportCenterX,
viewportCenterY,
viewportHalfX,
viewportHalfY,
AetheriaRuntimeRenderSplatChannels.Gravity,
AetheriaRuntimeRenderSplatFalloffs.Solid,
-zone.GravityTerrainDepth,
0,
0,
1,
"environment.gravity_terrain",
sourceKind: AetheriaRuntimeRenderSplatSourceKinds.AnimatedSimplexNoise,
frequencyX: 3.0,
frequencyY: 3.0,
animationSpeed: zone.GravityTerrainWaveFrequency * 0.025,
sourceFlags: 1);
}
splats.Add(
layerIndices[AetheriaRuntimeRenderSplatLayerKeys.FogSurfaceHeight],
viewportCenterX,
viewportCenterY,
viewportHalfX,
viewportHalfY,
AetheriaRuntimeRenderSplatChannels.Tint,
AetheriaRuntimeRenderSplatFalloffs.Solid,
1,
0,
0,
1,
"environment.fog_surface_height",
sourceKind: AetheriaRuntimeRenderSplatSourceKinds.AnimatedSimplexNoise,
frequencyX: 4.0,
frequencyY: 4.0,
animationSpeed: 0.015,
sourceFlags: 1);
splats.Add(
layerIndices[AetheriaRuntimeRenderSplatLayerKeys.FogPatchHeight],
viewportCenterX,
viewportCenterY,
viewportHalfX,
viewportHalfY,
AetheriaRuntimeRenderSplatChannels.Tint,
AetheriaRuntimeRenderSplatFalloffs.Solid,
1,
0,
0,
1,
"environment.fog_patch_height",
sourceKind: AetheriaRuntimeRenderSplatSourceKinds.AnimatedSimplexNoise,
frequencyX: 9.0,
frequencyY: 9.0,
animationSpeed: 0.02,
sourceFlags: 1);
splats.Add(
layerIndices[AetheriaRuntimeRenderSplatLayerKeys.FogPatch],
viewportCenterX,
viewportCenterY,
viewportHalfX,
viewportHalfY,
AetheriaRuntimeRenderSplatChannels.Tint,
AetheriaRuntimeRenderSplatFalloffs.Solid,
1,
0,
0,
1,
"environment.fog_patch",
sourceKind: AetheriaRuntimeRenderSplatSourceKinds.AnimatedSimplexNoise,
frequencyX: 6.0,
frequencyY: 6.0,
animationSpeed: 0.01,
sourceFlags: 1);
foreach (var body in zone.Bodies ?? Array.Empty<AetheriaRuntimeBodySnapshotCommit>())
{
if (!GravityInfluenceIntersectsViewport(body, normalizedViewport))
continue;
var radius = ResolveGravityRadius(body);
splats.Add(
layerIndices[AetheriaRuntimeRenderSplatLayerKeys.GravityHeight],
body.GravityInfluenceCenterX,
body.GravityInfluenceCenterZ,
radius,
radius,
AetheriaRuntimeRenderSplatChannels.Gravity,
AetheriaRuntimeRenderSplatFalloffs.InverseSmooth,
body.GravityWellDepth,
0,
0,
1,
body.BodyKey ?? "");
if (body.GravityWaveRadius > 0 && body.GravityWaveDepth != 0)
{
splats.Add(
layerIndices[AetheriaRuntimeRenderSplatLayerKeys.GravityWave],
body.GravityInfluenceCenterX,
body.GravityInfluenceCenterZ,
body.GravityWaveRadius,
body.GravityWaveRadius,
AetheriaRuntimeRenderSplatChannels.GravityWave,
AetheriaRuntimeRenderSplatFalloffs.Smooth,
body.GravityWaveDepth,
body.GravityWaveSpeed,
0,
1,
body.BodyKey ?? "");
}
if (IsBodyKind(body, "sun"))
{
var tintRadius = Math.Max(radius, Math.Max(32, body.BodyRadiusMultiplier * 70) *
Math.Max(0.01, body.SunVisual?.LightRadiusMultiplier ?? 1.0));
splats.Add(
layerIndices[AetheriaRuntimeRenderSplatLayerKeys.FogTint],
body.GravityInfluenceCenterX,
body.GravityInfluenceCenterZ,
tintRadius,
tintRadius,
AetheriaRuntimeRenderSplatChannels.Tint,
AetheriaRuntimeRenderSplatFalloffs.Smooth,
body.SunVisual?.FogTintColorX ?? 0,
body.SunVisual?.FogTintColorY ?? 0,
body.SunVisual?.FogTintColorZ ?? 0,
1,
body.BodyKey ?? "");
}
}
foreach (var entity in zone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
{
if (!IsPlayerControlled(entity))
continue;
var visibility = Math.Max(180, entity.Visibility);
if (entity.PositionX + visibility < normalizedViewport.MinX ||
entity.PositionX - visibility > normalizedViewport.MaxX ||
entity.PositionZ + visibility < normalizedViewport.MinY ||
entity.PositionZ - visibility > normalizedViewport.MaxY)
{
continue;
}
splats.Add(
layerIndices[AetheriaRuntimeRenderSplatLayerKeys.Visibility],
entity.PositionX,
entity.PositionZ,
visibility,
visibility,
AetheriaRuntimeRenderSplatChannels.Visibility,
AetheriaRuntimeRenderSplatFalloffs.Smooth,
1,
1,
1,
1,
BuildEntityKey(context.RunId, zone.ZoneIndex, entity.EntityIndex));
}
return new AetheriaRuntimeRenderSplatsViewportDocument
{
FrameId = frame.FrameId,
PublishedAtUtc = frame.PublishedAtUtc ?? "",
SimulationTimeSeconds = frame.SimulationTimeSeconds,
RunId = context.RunId,
ZoneIndex = zone.ZoneIndex,
ZoneName = string.IsNullOrWhiteSpace(zone.Name) ? $"Zone {zone.ZoneIndex}" : zone.Name,
Viewport = normalizedViewport,
Layers = layers,
Splats = splats.Build()
};
}
private static IReadOnlyList<AetheriaRuntimeRenderSplatLayerDefinition> BuildDefaultRenderSplatLayers()
{
return new[]
{
new AetheriaRuntimeRenderSplatLayerDefinition
{
LayerKey = AetheriaRuntimeRenderSplatLayerKeys.GravityHeight,
DisplayName = "Gravity Height",
Channel = AetheriaRuntimeRenderSplatChannels.Gravity,
BlendMode = AetheriaRuntimeRenderSplatBlendModes.Add,
GraphicsFormat = "R16_SFloat"
},
new AetheriaRuntimeRenderSplatLayerDefinition
{
LayerKey = AetheriaRuntimeRenderSplatLayerKeys.GravityWave,
DisplayName = "Gravity Wave",
Channel = AetheriaRuntimeRenderSplatChannels.GravityWave,
BlendMode = AetheriaRuntimeRenderSplatBlendModes.Add,
GraphicsFormat = "R16_SFloat"
},
new AetheriaRuntimeRenderSplatLayerDefinition
{
LayerKey = AetheriaRuntimeRenderSplatLayerKeys.Visibility,
DisplayName = "Visibility Mask",
Channel = AetheriaRuntimeRenderSplatChannels.Visibility,
BlendMode = AetheriaRuntimeRenderSplatBlendModes.Max,
GraphicsFormat = "R16_SFloat"
},
new AetheriaRuntimeRenderSplatLayerDefinition
{
LayerKey = AetheriaRuntimeRenderSplatLayerKeys.FogSurfaceHeight,
DisplayName = "Fog Surface Height",
Channel = AetheriaRuntimeRenderSplatChannels.Tint,
BlendMode = AetheriaRuntimeRenderSplatBlendModes.Add,
GraphicsFormat = "R16_SFloat"
},
new AetheriaRuntimeRenderSplatLayerDefinition
{
LayerKey = AetheriaRuntimeRenderSplatLayerKeys.FogPatchHeight,
DisplayName = "Fog Patch Height",
Channel = AetheriaRuntimeRenderSplatChannels.Tint,
BlendMode = AetheriaRuntimeRenderSplatBlendModes.Add,
GraphicsFormat = "R16_SFloat"
},
new AetheriaRuntimeRenderSplatLayerDefinition
{
LayerKey = AetheriaRuntimeRenderSplatLayerKeys.FogPatch,
DisplayName = "Fog Patch",
Channel = AetheriaRuntimeRenderSplatChannels.Tint,
BlendMode = AetheriaRuntimeRenderSplatBlendModes.Max,
GraphicsFormat = "R16_SFloat"
},
new AetheriaRuntimeRenderSplatLayerDefinition
{
LayerKey = AetheriaRuntimeRenderSplatLayerKeys.FogTint,
DisplayName = "Fog Tint",
Channel = AetheriaRuntimeRenderSplatChannels.Tint,
BlendMode = AetheriaRuntimeRenderSplatBlendModes.Add,
GraphicsFormat = "B10G11R11_UFloatPack32"
},
new AetheriaRuntimeRenderSplatLayerDefinition
{
LayerKey = AetheriaRuntimeRenderSplatLayerKeys.Influence,
DisplayName = "Influence",
Channel = AetheriaRuntimeRenderSplatChannels.Influence,
BlendMode = AetheriaRuntimeRenderSplatBlendModes.Add,
GraphicsFormat = "R16_SFloat"
}
};
}
public static AetheriaRuntimeCurrentZoneDocument ProjectCurrentZone(
AetheriaRuntimeDaemonFrameDocument frame)
{
@ -553,7 +820,7 @@ namespace GameCult.Aetheria.State.Verse
string runId,
int zoneIndex)
{
return new AetheriaRuntimeRtsViewportObject
var obj = new AetheriaRuntimeRtsViewportObject
{
EntityIndex = entity.EntityIndex,
EntityKey = BuildEntityKey(runId, zoneIndex, entity.EntityIndex),
@ -579,6 +846,8 @@ namespace GameCult.Aetheria.State.Verse
},
Inventory = Inventory(entity)
};
obj.IconAsset = AetheriaRuntimeAssets.ResolveEntityIcon(obj);
return obj;
}
private static AetheriaRuntimeRtsBodyView ToBodyView(AetheriaRuntimeBodySnapshotCommit body)
@ -1101,7 +1370,11 @@ namespace GameCult.Aetheria.State.Verse
Enabled = item.Enabled,
SourceIndex = sourceIndex,
X = slot.X,
Y = slot.Y
Y = slot.Y,
IconAsset = AetheriaRuntimeAssetRef.FromKey(
$"item.{item.ItemKey ?? ""}.icon",
AetheriaRuntimeAssetKinds.Texture,
$"item.{item.ItemKey ?? ""}.icon")
});
}
@ -1123,6 +1396,111 @@ namespace GameCult.Aetheria.State.Verse
return string.Equals(entity.FactionKey, "player", StringComparison.OrdinalIgnoreCase);
}
private static bool IsBodyKind(AetheriaRuntimeBodySnapshotCommit body, string kind)
{
return body != null &&
string.Equals(body.Kind ?? "", kind ?? "", StringComparison.OrdinalIgnoreCase);
}
private sealed class RenderSplatBuilder
{
private readonly List<double> _centerX = new List<double>();
private readonly List<double> _centerY = new List<double>();
private readonly List<double> _halfExtentX = new List<double>();
private readonly List<double> _halfExtentY = new List<double>();
private readonly List<double> _rotationCos = new List<double>();
private readonly List<double> _rotationSin = new List<double>();
private readonly List<int> _channel = new List<int>();
private readonly List<int> _falloff = new List<int>();
private readonly List<double> _valueR = new List<double>();
private readonly List<double> _valueG = new List<double>();
private readonly List<double> _valueB = new List<double>();
private readonly List<double> _valueA = new List<double>();
private readonly List<string> _sourceKey = new List<string>();
private readonly List<int> _layerIndex = new List<int>();
private readonly List<int> _sourceKind = new List<int>();
private readonly List<double> _frequencyX = new List<double>();
private readonly List<double> _frequencyY = new List<double>();
private readonly List<double> _phaseX = new List<double>();
private readonly List<double> _phaseY = new List<double>();
private readonly List<double> _animationSpeed = new List<double>();
private readonly List<double> _sourceFlags = new List<double>();
public void Add(
int layerIndex,
double centerX,
double centerY,
double halfExtentX,
double halfExtentY,
int channel,
int falloff,
double valueR,
double valueG,
double valueB,
double valueA,
string sourceKey,
double rotationRadians = 0,
int sourceKind = AetheriaRuntimeRenderSplatSourceKinds.Constant,
double frequencyX = 1,
double frequencyY = 1,
double phaseX = 0,
double phaseY = 0,
double animationSpeed = 0,
double sourceFlags = 0)
{
_layerIndex.Add(Math.Max(0, layerIndex));
_centerX.Add(centerX);
_centerY.Add(centerY);
_halfExtentX.Add(Math.Max(0, halfExtentX));
_halfExtentY.Add(Math.Max(0, halfExtentY));
_rotationCos.Add(Math.Cos(rotationRadians));
_rotationSin.Add(Math.Sin(rotationRadians));
_channel.Add(channel);
_falloff.Add(falloff);
_valueR.Add(valueR);
_valueG.Add(valueG);
_valueB.Add(valueB);
_valueA.Add(valueA);
_sourceKey.Add(sourceKey ?? "");
_sourceKind.Add(sourceKind);
_frequencyX.Add(frequencyX);
_frequencyY.Add(frequencyY);
_phaseX.Add(phaseX);
_phaseY.Add(phaseY);
_animationSpeed.Add(animationSpeed);
_sourceFlags.Add(sourceFlags);
}
public AetheriaRuntimeRenderSplatSoa Build()
{
return new AetheriaRuntimeRenderSplatSoa
{
Count = _centerX.Count,
CenterX = _centerX.ToArray(),
CenterY = _centerY.ToArray(),
HalfExtentX = _halfExtentX.ToArray(),
HalfExtentY = _halfExtentY.ToArray(),
RotationCos = _rotationCos.ToArray(),
RotationSin = _rotationSin.ToArray(),
Channel = _channel.ToArray(),
Falloff = _falloff.ToArray(),
ValueR = _valueR.ToArray(),
ValueG = _valueG.ToArray(),
ValueB = _valueB.ToArray(),
ValueA = _valueA.ToArray(),
SourceKey = _sourceKey.ToArray(),
LayerIndex = _layerIndex.ToArray(),
SourceKind = _sourceKind.ToArray(),
FrequencyX = _frequencyX.ToArray(),
FrequencyY = _frequencyY.ToArray(),
PhaseX = _phaseX.ToArray(),
PhaseY = _phaseY.ToArray(),
AnimationSpeed = _animationSpeed.ToArray(),
SourceFlags = _sourceFlags.ToArray()
};
}
}
private static ProjectionContext Context(AetheriaRuntimeDaemonFrameDocument frame)
{
var run = frame.Run ?? new AetheriaRuntimeRunCheckpointCommit();

View file

@ -1123,6 +1123,10 @@ namespace GameCult.Aetheria.State.Verse
[Key(17)]
public IReadOnlyList<AetheriaRuntimeRtsInventoryItem> Inventory { get; set; } =
Array.Empty<AetheriaRuntimeRtsInventoryItem>();
[Key(18)]
public AetheriaRuntimeAssetRef IconAsset { get; set; } =
AetheriaRuntimeAssetRef.Empty(AetheriaRuntimeAssetKinds.Sprite);
}
[MessagePackObject]
@ -1167,6 +1171,10 @@ namespace GameCult.Aetheria.State.Verse
[Key(8)]
public int Y { get; set; } = -1;
[Key(9)]
public AetheriaRuntimeAssetRef IconAsset { get; set; } =
AetheriaRuntimeAssetRef.Empty(AetheriaRuntimeAssetKinds.Texture);
}
[MessagePackObject]

View file

@ -75,6 +75,8 @@ namespace GameCult.Aetheria.State.Verse
[Key(2)] public double Quality { get; set; }
[Key(3)] public double Durability { get; set; }
[Key(4)] public string Source { get; set; } = "station";
[Key(5)] public AetheriaRuntimeAssetRef IconAsset { get; set; } =
AetheriaRuntimeAssetRef.Empty(AetheriaRuntimeAssetKinds.Texture);
}
[MessagePackObject]
@ -122,7 +124,8 @@ namespace GameCult.Aetheria.State.Verse
public static AetheriaRuntimeStarbridgeSessionSummaryDocument ProjectSessionSummary(
AetheriaRuntimeDaemonFrameDocument frame,
AetheriaRuntimeStarbridgeScenarioDocument? scenario = null,
AetheriaRuntimeStarbridgeSessionDocument? session = null)
AetheriaRuntimeStarbridgeSessionDocument? session = null,
AetheriaRuntimeCatalogSnapshot? catalog = null)
{
frame ??= new AetheriaRuntimeDaemonFrameDocument();
var run = frame.Run ?? new AetheriaRuntimeRunCheckpointCommit();
@ -145,7 +148,7 @@ namespace GameCult.Aetheria.State.Verse
Phase = FirstNonEmpty(session?.Phase, "setup"),
CurrentWaveIndex = Math.Max(0, session?.CurrentWaveIndex ?? 0),
BaseStatus = ToBaseStatus(baseEntity, runId, zone.ZoneIndex),
StationStock = ResolveStationStock(scenario, session, baseEntity),
StationStock = ResolveStationStock(scenario, session, baseEntity, catalog),
WaveForecast = ResolveWaveForecast(scenario, session),
RuntimeRoles = ResolveRuntimeRoles(scenario, session)
};
@ -215,10 +218,11 @@ namespace GameCult.Aetheria.State.Verse
private static AetheriaRuntimeStarbridgeStationStockItem[] ResolveStationStock(
AetheriaRuntimeStarbridgeScenarioDocument? scenario,
AetheriaRuntimeStarbridgeSessionDocument? session,
AetheriaRuntimeEntitySnapshotCommit? baseEntity)
AetheriaRuntimeEntitySnapshotCommit? baseEntity,
AetheriaRuntimeCatalogSnapshot? catalog)
{
if (scenario?.StationStock?.Length > 0)
return scenario.StationStock;
return scenario.StationStock.Select(item => WithIconAsset(item, catalog)).ToArray();
if (baseEntity == null)
return Array.Empty<AetheriaRuntimeStarbridgeStationStockItem>();
@ -233,11 +237,40 @@ namespace GameCult.Aetheria.State.Verse
Quantity = item.Quantity,
Quality = item.Quality,
Durability = item.Durability,
Source = string.IsNullOrWhiteSpace(session?.StationEntityKey) ? "base-cargo" : session!.StationEntityKey
Source = string.IsNullOrWhiteSpace(session?.StationEntityKey) ? "base-cargo" : session!.StationEntityKey,
IconAsset = ResolveItemIconAsset(item.ItemKey, catalog)
})
.ToArray();
}
private static AetheriaRuntimeStarbridgeStationStockItem WithIconAsset(
AetheriaRuntimeStarbridgeStationStockItem item,
AetheriaRuntimeCatalogSnapshot? catalog)
{
if (item == null)
return new AetheriaRuntimeStarbridgeStationStockItem();
item.IconAsset = ResolveItemIconAsset(item.ItemKey, catalog);
return item;
}
private static AetheriaRuntimeAssetRef ResolveItemIconAsset(
string? itemKey,
AetheriaRuntimeCatalogSnapshot? catalog)
{
itemKey ??= "";
var typedItem = catalog?.FindItem(itemKey);
var icon = AetheriaRuntimeAssets.AssetRefFromCatalogIcon(
typedItem?.ActionBarIcon,
$"item.{itemKey}.icon");
return string.IsNullOrWhiteSpace(icon.AssetKey)
? AetheriaRuntimeAssetRef.FromKey(
$"item.{itemKey}.icon",
AetheriaRuntimeAssetKinds.Texture,
$"item.{itemKey}.icon")
: icon;
}
private static AetheriaRuntimeStarbridgeWaveForecast[] ResolveWaveForecast(
AetheriaRuntimeStarbridgeScenarioDocument? scenario,
AetheriaRuntimeStarbridgeSessionDocument? session)

View file

@ -10,6 +10,7 @@ namespace GameCult.Aetheria.State.Verse
public const string RuntimeReplicaDirectoryName = "Verses";
public const string RuntimeDaemonFrameFileSuffix = ".daemon.frame.cc";
public const string RuntimeDaemonSoaViewFileSuffix = ".daemon.soa.cc";
public const string RuntimeDaemonAssetManifestFileSuffix = ".daemon.assets.cc";
public const string RuntimeDaemonProviderFileSuffix = ".daemon.provider.cc";
public const string RuntimeDaemonHealthFileSuffix = ".daemon.health.cc";
public const string RuntimeVerseAuthorityPolicyFileSuffix = ".authority.policy.cc";
@ -44,6 +45,11 @@ namespace GameCult.Aetheria.State.Verse
return stateFilePath + RuntimeDaemonSoaViewFileSuffix;
}
public static string GetDaemonAssetManifestPath(string stateFilePath)
{
return stateFilePath + RuntimeDaemonAssetManifestFileSuffix;
}
public static string GetDaemonProviderPath(string stateFilePath)
{
return stateFilePath + RuntimeDaemonProviderFileSuffix;

View file

@ -89,6 +89,7 @@ namespace GameCult.Aetheria.State.Verse
typeof(AetheriaRuntimeDaemonCommandBoundaryDocument),
typeof(AetheriaRuntimeDaemonFrameDocument),
typeof(AetheriaRuntimeDaemonSoaViewDocument),
typeof(AetheriaRuntimeAssetManifestDocument),
typeof(AetheriaRuntimeObjectsViewportDocument),
typeof(AetheriaRuntimeGravityViewportDocument),
typeof(AetheriaRuntimeCurrentZoneDocument),