Add managed settings documents

This commit is contained in:
Meta Vens 2026-06-28 01:46:18 +01:00
commit 9973adad55
8 changed files with 280 additions and 4 deletions

View file

@ -985,6 +985,7 @@ static void RequirePackageSerializerBoundary(string root)
"AetheriaRuntimeRtsViewportDocuments.cs",
"AetheriaRuntimeAssetDocuments.cs",
"AetheriaRuntimeRenderSplatDocuments.cs",
"AetheriaRuntimeSettingsDocuments.cs",
"AetheriaRuntimeStarbridgeDocuments.cs",
"AetheriaRuntimeStarbridgePlayerSeatDocuments.cs",
"AetheriaRuntimeVerseAuthorityPolicy.cs"

View file

@ -168,6 +168,8 @@ public class DaemonRuntimeDocumentTests
var currentEntity = client.Aetheria().Current.Entity.LatestAsync().GetAwaiter().GetResult();
var latestFrame = client.Aetheria().LatestFrame.LatestAsync().GetAwaiter().GetResult();
var playerSettings = client.Aetheria().Settings.Player.LatestAsync().GetAwaiter().GetResult();
var verseHostSettings = client.Aetheria().Settings.VerseHost.LatestAsync().GetAwaiter().GetResult();
var currentEntityByType = client.Aetheria()
.LatestAsync<AetheriaRuntimeCurrentEntityDocument>()
.GetAwaiter()
@ -217,6 +219,8 @@ public class DaemonRuntimeDocumentTests
Assert.AreSame(client.State.Current.Entity, client.State.Document<AetheriaRuntimeCurrentEntityDocument>());
Assert.AreSame(client.State.ZoneRender, client.Document<AetheriaRuntimeZoneRenderDocument>());
Assert.AreSame(client.State.LatestFrame, client.Document<AetheriaRuntimeDaemonFrameDocument>());
Assert.AreSame(client.State.Settings.Player, client.Document<AetheriaRuntimePlayerSettingsDocument>());
Assert.AreSame(client.State.Settings.VerseHost, client.Document<AetheriaRuntimeVerseHostSettingsDocument>());
Assert.AreSame(
client.State.Current.Entity,
client.State.DocumentBySchema(AetheriaRuntimeDaemonSchemas.CurrentEntity));
@ -236,6 +240,8 @@ public class DaemonRuntimeDocumentTests
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.Frame, latestFrame.Schema);
Assert.AreEqual(frame.FrameId, latestFrame.FrameId);
Assert.AreEqual(frame.FrameId, latestFrameByType.FrameId);
Assert.AreEqual(AetheriaRuntimePlayerSettingsDocument.SchemaId, playerSettings.Schema);
Assert.AreEqual(AetheriaRuntimeVerseHostSettingsDocument.SchemaId, verseHostSettings.Schema);
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.ObjectsViewport, objectsViewport.Schema);
Assert.AreEqual("Player", objectsViewport.Objects.FirstOrDefault()?.DisplayName);
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.ZoneDetails, zoneDetails.Schema);
@ -256,6 +262,31 @@ public class DaemonRuntimeDocumentTests
source.SourceId == "catalog:aetheria.runtime"));
}
[Test]
public void AetheriaClientSettingsDocumentsDoNotRequireDaemonFrame()
{
var statePath = Path.Combine(
Path.GetTempPath(),
"aetheria-client-settings-doc-tests",
Path.GetRandomFileName(),
"state.cc");
using var client = AetheriaClient
.OpenAsync(statePath, "settings-test", pullOnOpen: true)
.GetAwaiter()
.GetResult();
var player = client.Aetheria().Settings.Player.LatestAsync().GetAwaiter().GetResult();
var verseHost = client.Aetheria().Settings.VerseHost.LatestAsync().GetAwaiter().GetResult();
Assert.AreEqual(AetheriaRuntimePlayerSettingsDocument.SchemaId, player.Schema);
Assert.AreEqual(AetheriaRuntimeVerseHostSettingsDocument.SchemaId, verseHost.Schema);
Assert.AreEqual("", player.PlayerName);
Assert.AreEqual("", verseHost.VerseId);
Assert.AreSame(client.State.Settings.Player, client.Document<AetheriaRuntimePlayerSettingsDocument>());
Assert.AreSame(client.State.Settings.VerseHost, client.Document<AetheriaRuntimeVerseHostSettingsDocument>());
}
[Test]
public void AetheriaRuntimeVerseClientExposesDomainStateFacade()
{

View file

@ -79,6 +79,7 @@
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonPublicationStore.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeInputSettingsSurfaceBuilder.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeItemCategories.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeSettingsDocuments.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonSurfaceCommandCatalog.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeEveCommandClient.cs" />
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeAssetDocuments.cs" />

View file

@ -140,16 +140,18 @@ namespace GameCult.Aetheria.State.Verse
return _verse.OpenRuntimeCatalog();
}
public Task<AetheriaRuntimePlayerSettingsSnapshot?> PlayerSettingsAsync()
public async Task<AetheriaRuntimePlayerSettingsSnapshot?> PlayerSettingsAsync()
{
ThrowIfDisposed();
return _verse.GetPlayerSettingsAsync();
var document = await State.Settings.Player.LatestAsync().ConfigureAwait(false);
return document.ToSnapshot();
}
public Task<AetheriaRuntimeVerseHostSettingsSnapshot?> VerseHostSettingsAsync()
public async Task<AetheriaRuntimeVerseHostSettingsSnapshot?> VerseHostSettingsAsync()
{
ThrowIfDisposed();
return _verse.GetVerseHostSettingsAsync();
var document = await State.Settings.VerseHost.LatestAsync().ConfigureAwait(false);
return document.ToSnapshot();
}
public Task<System.Collections.Generic.IReadOnlyList<AetheriaRuntimeLoadoutTemplateSnapshot>> LoadoutTemplatesAsync()

View file

@ -15,6 +15,8 @@ namespace GameCult.Aetheria.State.Verse
internal AetheriaClientState(
CultMeshDocumentHandle<AetheriaRuntimeDaemonFrameDocument> latestFrame,
CultMeshDocumentHandle<AetheriaRuntimeDaemonSoaViewDocument> latestSoaView,
CultMeshDocumentHandle<AetheriaRuntimePlayerSettingsDocument> playerSettings,
CultMeshDocumentHandle<AetheriaRuntimeVerseHostSettingsDocument> verseHostSettings,
CultMeshDocumentHandle<AetheriaRuntimeCurrentZoneDocument> currentZone,
CultMeshDocumentHandle<AetheriaRuntimeCurrentEntityDocument> currentEntity,
CultMeshDocumentHandle<AetheriaRuntimeCurrentDockingDocument> currentDocking,
@ -36,6 +38,7 @@ namespace GameCult.Aetheria.State.Verse
{
LatestFrame = latestFrame ?? throw new ArgumentNullException(nameof(latestFrame));
LatestSoaView = latestSoaView ?? throw new ArgumentNullException(nameof(latestSoaView));
Settings = new AetheriaClientSettingsState(playerSettings, verseHostSettings);
Current = new AetheriaClientCurrentState(currentZone, currentEntity, currentDocking);
ZoneContacts = zoneContacts ?? throw new ArgumentNullException(nameof(zoneContacts));
StationRefit = stationRefit ?? throw new ArgumentNullException(nameof(stationRefit));
@ -59,6 +62,8 @@ namespace GameCult.Aetheria.State.Verse
_documents = CultMesh.Documents(
LatestFrame,
LatestSoaView,
Settings.Player,
Settings.VerseHost,
Current.Zone,
Current.Entity,
Current.Docking,
@ -74,6 +79,8 @@ namespace GameCult.Aetheria.State.Verse
public CultMeshDocumentHandle<AetheriaRuntimeDaemonSoaViewDocument> LatestSoaView { get; }
public AetheriaClientSettingsState Settings { get; }
public AetheriaClientCurrentState Current { get; }
public AetheriaClientDockingState DockingState { get; }
@ -184,6 +191,21 @@ namespace GameCult.Aetheria.State.Verse
public CultMeshDocumentHandle<AetheriaRuntimeCurrentDockingDocument> Docking { get; }
}
public sealed class AetheriaClientSettingsState
{
internal AetheriaClientSettingsState(
CultMeshDocumentHandle<AetheriaRuntimePlayerSettingsDocument> player,
CultMeshDocumentHandle<AetheriaRuntimeVerseHostSettingsDocument> verseHost)
{
Player = player ?? throw new ArgumentNullException(nameof(player));
VerseHost = verseHost ?? throw new ArgumentNullException(nameof(verseHost));
}
public CultMeshDocumentHandle<AetheriaRuntimePlayerSettingsDocument> Player { get; }
public CultMeshDocumentHandle<AetheriaRuntimeVerseHostSettingsDocument> VerseHost { get; }
}
public sealed class AetheriaClientDockingState
{
private readonly CultMeshDocumentHandle<AetheriaRuntimeCurrentEntityDocument> _currentEntity;

View file

@ -0,0 +1,180 @@
using System;
using System.Linq;
using GameCult.Caching;
using MessagePack;
#nullable enable
namespace GameCult.Aetheria.State.Verse
{
[CultDocument("gamecult.aetheria.player_settings", "gamecult.aetheria.player_settings.v1")]
[MessagePackObject]
public sealed class AetheriaRuntimePlayerSettingsDocument
{
public const string SchemaId = "gamecult.aetheria.player_settings.v1";
[Key(0)] public string Schema { get; set; } = SchemaId;
[Key(1)] public string PlayerName { get; set; } = "";
[Key(2)] public bool TutorialPassed { get; set; }
[Key(3)] public AetheriaRuntimeStoryFileHashDocument[] StoryFileHashes { get; set; } =
Array.Empty<AetheriaRuntimeStoryFileHashDocument>();
[Key(4)] public string TemperatureUnit { get; set; } = "";
[Key(5)] public int SignificantDigits { get; set; }
[Key(6)] public double DefaultShutdownPerformance { get; set; }
[Key(7)] public string NebulaQuality { get; set; } = "";
[Key(8)] public bool ShowAsteroidsInMinimap { get; set; }
[Key(9)] public AetheriaRuntimeInputBindingOverrideDocument[] BindingOverrides { get; set; } =
Array.Empty<AetheriaRuntimeInputBindingOverrideDocument>();
[Key(10)] public string[] ActionBarInputs { get; set; } = Array.Empty<string>();
public static AetheriaRuntimePlayerSettingsDocument FromSnapshot(
AetheriaRuntimePlayerSettingsSnapshot? snapshot)
{
snapshot ??= new AetheriaRuntimePlayerSettingsSnapshot(
"",
false,
Array.Empty<AetheriaRuntimeStoryFileHash>(),
"",
0,
0,
"",
false,
Array.Empty<AetheriaRuntimeInputBindingOverride>(),
Array.Empty<string>());
return new AetheriaRuntimePlayerSettingsDocument
{
PlayerName = snapshot.PlayerName ?? "",
TutorialPassed = snapshot.TutorialPassed,
StoryFileHashes = (snapshot.StoryFileHashes ?? Array.Empty<AetheriaRuntimeStoryFileHash>())
.Select(AetheriaRuntimeStoryFileHashDocument.FromSnapshot)
.ToArray(),
TemperatureUnit = snapshot.TemperatureUnit ?? "",
SignificantDigits = snapshot.SignificantDigits,
DefaultShutdownPerformance = snapshot.DefaultShutdownPerformance,
NebulaQuality = snapshot.NebulaQuality ?? "",
ShowAsteroidsInMinimap = snapshot.ShowAsteroidsInMinimap,
BindingOverrides = (snapshot.BindingOverrides ?? Array.Empty<AetheriaRuntimeInputBindingOverride>())
.Select(AetheriaRuntimeInputBindingOverrideDocument.FromSnapshot)
.ToArray(),
ActionBarInputs = (snapshot.ActionBarInputs ?? Array.Empty<string>())
.Where(input => !string.IsNullOrWhiteSpace(input))
.ToArray()
};
}
public AetheriaRuntimePlayerSettingsSnapshot ToSnapshot()
{
return new AetheriaRuntimePlayerSettingsSnapshot(
PlayerName ?? "",
TutorialPassed,
(StoryFileHashes ?? Array.Empty<AetheriaRuntimeStoryFileHashDocument>())
.Select(hash => hash.ToSnapshot())
.ToArray(),
TemperatureUnit ?? "",
SignificantDigits,
DefaultShutdownPerformance,
NebulaQuality ?? "",
ShowAsteroidsInMinimap,
(BindingOverrides ?? Array.Empty<AetheriaRuntimeInputBindingOverrideDocument>())
.Select(binding => binding.ToSnapshot())
.ToArray(),
ActionBarInputs ?? Array.Empty<string>());
}
}
[MessagePackObject]
public sealed class AetheriaRuntimeStoryFileHashDocument
{
[Key(0)] public string StoryPath { get; set; } = "";
[Key(1)] public string Hash { get; set; } = "";
public static AetheriaRuntimeStoryFileHashDocument FromSnapshot(AetheriaRuntimeStoryFileHash snapshot)
{
return new AetheriaRuntimeStoryFileHashDocument
{
StoryPath = snapshot?.StoryPath ?? "",
Hash = snapshot?.Hash ?? ""
};
}
public AetheriaRuntimeStoryFileHash ToSnapshot()
{
return new AetheriaRuntimeStoryFileHash(StoryPath ?? "", Hash ?? "");
}
}
[MessagePackObject]
public sealed class AetheriaRuntimeInputBindingOverrideDocument
{
[Key(0)] public string ActionName { get; set; } = "";
[Key(1)] public int BindingIndex { get; set; }
[Key(2)] public string BindingPath { get; set; } = "";
public static AetheriaRuntimeInputBindingOverrideDocument FromSnapshot(
AetheriaRuntimeInputBindingOverride snapshot)
{
return new AetheriaRuntimeInputBindingOverrideDocument
{
ActionName = snapshot?.ActionName ?? "",
BindingIndex = snapshot?.BindingIndex ?? -1,
BindingPath = snapshot?.BindingPath ?? ""
};
}
public AetheriaRuntimeInputBindingOverride ToSnapshot()
{
return new AetheriaRuntimeInputBindingOverride(ActionName ?? "", BindingIndex, BindingPath ?? "");
}
}
[CultDocument("gamecult.aetheria.verse_host_settings", "gamecult.aetheria.verse_host_settings.v1")]
[MessagePackObject]
public sealed class AetheriaRuntimeVerseHostSettingsDocument
{
public const string SchemaId = "gamecult.aetheria.verse_host_settings.v1";
[Key(0)] public string Schema { get; set; } = SchemaId;
[Key(1)] public string ServiceId { get; set; } = "";
[Key(2)] public string VerseId { get; set; } = "";
[Key(3)] public string RootVerse { get; set; } = "";
[Key(4)] public string CanonicalService { get; set; } = "";
[Key(5)] public string LocatedService { get; set; } = "";
[Key(6)] public string CultMeshAddress { get; set; } = "";
[Key(7)] public string Title { get; set; } = "";
[Key(8)] public string Visibility { get; set; } = "";
[Key(9)] public string LastUpdatedAtUtc { get; set; } = "";
public static AetheriaRuntimeVerseHostSettingsDocument FromSnapshot(
AetheriaRuntimeVerseHostSettingsSnapshot? snapshot)
{
snapshot ??= new AetheriaRuntimeVerseHostSettingsSnapshot("", "", "", "", "", "", "", "", "");
return new AetheriaRuntimeVerseHostSettingsDocument
{
ServiceId = snapshot.ServiceId ?? "",
VerseId = snapshot.VerseId ?? "",
RootVerse = snapshot.RootVerse ?? "",
CanonicalService = snapshot.CanonicalService ?? "",
LocatedService = snapshot.LocatedService ?? "",
CultMeshAddress = snapshot.CultMeshAddress ?? "",
Title = snapshot.Title ?? "",
Visibility = snapshot.Visibility ?? "",
LastUpdatedAtUtc = snapshot.LastUpdatedAtUtc ?? ""
};
}
public AetheriaRuntimeVerseHostSettingsSnapshot ToSnapshot()
{
return new AetheriaRuntimeVerseHostSettingsSnapshot(
ServiceId ?? "",
VerseId ?? "",
RootVerse ?? "",
CanonicalService ?? "",
LocatedService ?? "",
CultMeshAddress ?? "",
Title ?? "",
Visibility ?? "",
LastUpdatedAtUtc ?? "");
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a8f86fccf9cdb0c4cb2a03626050f593

View file

@ -107,6 +107,8 @@ namespace GameCult.Aetheria.State.Verse
typeof(AetheriaRuntimeStarbridgeSessionDocument),
typeof(AetheriaRuntimeStarbridgeSessionSummaryDocument),
typeof(AetheriaRuntimeStarbridgePlayerSeatDocument),
typeof(AetheriaRuntimePlayerSettingsDocument),
typeof(AetheriaRuntimeVerseHostSettingsDocument),
typeof(AetheriaRuntimeDaemonCommandDocument),
typeof(AetheriaRuntimeEveCommandDocument),
typeof(EveSurfaceState)
@ -732,6 +734,18 @@ namespace GameCult.Aetheria.State.Verse
AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest),
Document<AetheriaRuntimeDaemonSoaViewDocument>(
AetheriaRuntimeVerseRecordKeys.DaemonSoaViewLatest),
CatalogDocument(
"aetheria.settings.player",
() => Task.FromResult(AetheriaRuntimePlayerSettingsDocument.FromSnapshot(
AetheriaRuntimeCatalogStore.ReadPlayerSettings(StatePath))),
AetheriaRuntimePlayerSettingsDocument.SchemaId,
CultMesh.ProjectionSource("catalog:aetheria.player_settings")),
CatalogDocument(
"aetheria.settings.verse_host",
() => Task.FromResult(AetheriaRuntimeVerseHostSettingsDocument.FromSnapshot(
AetheriaRuntimeCatalogStore.ReadVerseHostSettings(StatePath))),
AetheriaRuntimeVerseHostSettingsDocument.SchemaId,
CultMesh.ProjectionSource("catalog:aetheria.verse_host_settings")),
ProjectedDocument(
"aetheria.current.zone",
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectCurrentZone(frame)),
@ -834,6 +848,29 @@ namespace GameCult.Aetheria.State.Verse
routeHint: new CultMeshRouteHint(CultMeshLocalityKind.SharedMemory, "Aetheria typed projected state"));
}
CultMeshDocumentHandle<TDocument> CatalogDocument<TDocument>(
string documentId,
Func<Task<TDocument>> project,
string schemaId,
params CultMeshProjectionSource[] additionalSources)
where TDocument : class
{
var sources = (additionalSources ?? Array.Empty<CultMeshProjectionSource>())
.Append(CultMesh.ProjectionSource(documentId, schemaId, "projected Aetheria catalog document"))
.ToArray();
var verse = CultMesh.Verse("aetheria.local", RuntimeId);
return CultMesh.Document(
documentId,
verse,
async _ => await project().ConfigureAwait(false),
_ => frameChanges
.SelectAwait(async (_, cancellationToken) =>
await project().ConfigureAwait(false)),
sources: sources,
routeHint: new CultMeshRouteHint(CultMeshLocalityKind.SharedMemory, "Aetheria typed catalog state"));
}
async Task<AetheriaRuntimeStationRefitDocument> ProjectStationRefitAsync(
AetheriaRuntimeDaemonFrameDocument frame)
{