Publish player settings as a provider-owned Eve surface

This commit is contained in:
Meta Vens 2026-06-16 18:09:15 +01:00
commit be6d7b3b25
14 changed files with 534 additions and 70 deletions

View file

@ -7,6 +7,7 @@ public sealed class AetheriaEveCommandApplyReport
{
public int AppliedCatalogRefreshes { get; set; }
public int AppliedOperationsRefreshes { get; set; }
public int AppliedPlayerSettingsCommands { get; set; }
public int RejectedCommands { get; set; }
public string[] AcceptedPaths { get; set; } = [];
public string[] RejectedPaths { get; set; } = [];
@ -66,6 +67,15 @@ public static class AetheriaEveCommandBridge
AetheriaOperationsSurfaceProjector.Build(commitStatus, eveStatus)).ConfigureAwait(false);
report.AppliedOperationsRefreshes++;
break;
case "aetheria.player_settings.refresh":
case "aetheria.player_settings.gameplay.temperature_unit.cycle":
case "aetheria.player_settings.gameplay.significant_digits.decrement":
case "aetheria.player_settings.gameplay.significant_digits.increment":
case "aetheria.player_settings.graphics.nebula_quality.cycle":
case "aetheria.player_settings.graphics.show_asteroids.toggle":
await ApplyPlayerSettingsCommandAsync(node, command).ConfigureAwait(false);
report.AppliedPlayerSettingsCommands++;
break;
}
accepted.Add(path);
@ -101,7 +111,85 @@ public static class AetheriaEveCommandBridge
return (string.Equals(surfaceId, AetheriaCatalogSurfaceProjector.SurfaceId, StringComparison.Ordinal) &&
string.Equals(command, "aetheria.catalog.refresh", StringComparison.Ordinal)) ||
(string.Equals(surfaceId, AetheriaOperationsSurfaceProjector.SurfaceId, StringComparison.Ordinal) &&
string.Equals(command, "aetheria.operations.refresh", StringComparison.Ordinal));
string.Equals(command, "aetheria.operations.refresh", StringComparison.Ordinal)) ||
(string.Equals(surfaceId, AetheriaPlayerSettingsSurfaceProjector.SurfaceId, StringComparison.Ordinal) &&
KnownPlayerSettingsCommand(command));
}
private static bool KnownPlayerSettingsCommand(string command)
{
return string.Equals(command, "aetheria.player_settings.refresh", StringComparison.Ordinal) ||
string.Equals(command, "aetheria.player_settings.gameplay.temperature_unit.cycle", StringComparison.Ordinal) ||
string.Equals(command, "aetheria.player_settings.gameplay.significant_digits.decrement", StringComparison.Ordinal) ||
string.Equals(command, "aetheria.player_settings.gameplay.significant_digits.increment", StringComparison.Ordinal) ||
string.Equals(command, "aetheria.player_settings.graphics.nebula_quality.cycle", StringComparison.Ordinal) ||
string.Equals(command, "aetheria.player_settings.graphics.show_asteroids.toggle", StringComparison.Ordinal);
}
private static async Task ApplyPlayerSettingsCommandAsync(
AetheriaStateNode node,
AetheriaRuntimeEveCommandDocument command)
{
var settings = await node.GetPlayerSettingsAsync().ConfigureAwait(false) ?? new AetheriaPlayerSettings();
settings.Gameplay ??= new AetheriaPlayerGameplaySettings();
settings.Graphics ??= new AetheriaPlayerGraphicsSettings();
var persistSettings = false;
switch (command.Command)
{
case "aetheria.player_settings.gameplay.temperature_unit.cycle":
settings.Gameplay.TemperatureUnit = Cycle(
settings.Gameplay.TemperatureUnit,
"Kelvin",
"Celsius",
"Fahrenheit");
persistSettings = true;
break;
case "aetheria.player_settings.gameplay.significant_digits.decrement":
settings.Gameplay.SignificantDigits = Math.Max(0, settings.Gameplay.SignificantDigits - 1);
persistSettings = true;
break;
case "aetheria.player_settings.gameplay.significant_digits.increment":
if (settings.Gameplay.SignificantDigits < int.MaxValue)
settings.Gameplay.SignificantDigits++;
persistSettings = true;
break;
case "aetheria.player_settings.graphics.nebula_quality.cycle":
settings.Graphics.NebulaQuality = Cycle(
settings.Graphics.NebulaQuality,
"Low",
"Normal",
"High",
"Ultra");
persistSettings = true;
break;
case "aetheria.player_settings.graphics.show_asteroids.toggle":
settings.Graphics.ShowAsteroidsInMinimap = !settings.Graphics.ShowAsteroidsInMinimap;
persistSettings = true;
break;
}
if (persistSettings)
{
settings.LastUpdatedAtUtc = command.IssuedAtUtc;
await node.PutPlayerSettingsAsync(settings).ConfigureAwait(false);
}
await node.PutPlayerSettingsSurfaceAsync(
AetheriaPlayerSettingsSurfaceProjector.Build(settings, command.IssuedAtUtc))
.ConfigureAwait(false);
}
private static string Cycle(string current, params string[] values)
{
if (values.Length == 0)
return current;
var index = Array.FindIndex(values, value => string.Equals(value, current, StringComparison.Ordinal));
if (index < 0)
return values[0];
return values[(index + 1) % values.Length];
}
private static void RecordRejection(

View file

@ -58,6 +58,7 @@ public static class AetheriaOperationsSurfaceProjector
Metric("eveCommandDrain.rejected", "Commands Rejected", (eveCommandStatus?.CommandsRejected ?? 0).ToString()),
Metric("eveCommandDrain.catalogRefreshes", "Catalog Refreshes", (eveCommandStatus?.AppliedCatalogRefreshes ?? 0).ToString()),
Metric("eveCommandDrain.operationsRefreshes", "Operations Refreshes", (eveCommandStatus?.AppliedOperationsRefreshes ?? 0).ToString()),
Metric("eveCommandDrain.playerSettings", "Player Settings Commands", (eveCommandStatus?.AppliedPlayerSettingsCommands ?? 0).ToString()),
Metric("eveCommandDrain.failures", "Consecutive Failures", (eveCommandStatus?.ConsecutiveFailures ?? 0).ToString()),
Row(
"eveCommandDrain.last",

View file

@ -0,0 +1,177 @@
using System.Linq;
using Aetheria.State.Documents;
namespace Aetheria.State;
public static class AetheriaPlayerSettingsSurfaceProjector
{
public const string SurfaceKey = "eve:surface:aetheria.player_settings";
public const string SurfaceId = "aetheria.player_settings";
public static EveSurfaceState Build(
AetheriaPlayerSettings? settings,
string updatedAtUtc,
long version = 1)
{
settings ??= new AetheriaPlayerSettings();
var gameplay = settings.Gameplay ?? new AetheriaPlayerGameplaySettings();
var graphics = settings.Graphics ?? new AetheriaPlayerGraphicsSettings();
var publishedAtUtc = !string.IsNullOrWhiteSpace(settings.LastUpdatedAtUtc)
? settings.LastUpdatedAtUtc
: updatedAtUtc;
return new EveSurfaceState
{
ProviderId = "aetheria",
ProviderKind = "game.runtime",
Title = "Aetheria Player Settings",
Version = version,
UpdatedAtUtc = publishedAtUtc,
Surface = new EveSurface
{
Id = SurfaceId,
Root = Node(
"aetheria.playerSettings.root",
"surface",
[],
Node(
"aetheria.playerSettings.summary",
"card",
[("title", "Player Settings")],
Row(
"playerSettings.summary.values",
("playerName", settings.PlayerName),
("tutorialPassed", settings.TutorialPassed ? "Yes" : "No"),
("activeRun", settings.ActiveRunKey)),
Text(
"playerSettings.summary.note",
"Input remapping still lives on the runtime-owned screen until Eve grows typed rebinding controls.")),
Node(
"aetheria.playerSettings.gameplay",
"card",
[("title", "Gameplay")],
Metric("playerSettings.gameplay.temperatureUnit", "Temperature Unit", gameplay.TemperatureUnit),
ButtonRow(
"playerSettings.gameplay.temperatureUnit.buttons",
Button(
"playerSettings.gameplay.temperatureUnit.cycle",
"Cycle Temperature Unit",
"aetheria.player_settings.gameplay.temperature_unit.cycle")),
Metric(
"playerSettings.gameplay.significantDigits",
"Significant Digits",
gameplay.SignificantDigits.ToString()),
ButtonRow(
"playerSettings.gameplay.significantDigits.buttons",
Button(
"playerSettings.gameplay.significantDigits.decrement",
"Digits -",
"aetheria.player_settings.gameplay.significant_digits.decrement"),
Button(
"playerSettings.gameplay.significantDigits.increment",
"Digits +",
"aetheria.player_settings.gameplay.significant_digits.increment"))),
Node(
"aetheria.playerSettings.graphics",
"card",
[("title", "Graphics")],
Metric("playerSettings.graphics.nebulaQuality", "Nebula Quality", graphics.NebulaQuality),
ButtonRow(
"playerSettings.graphics.nebulaQuality.buttons",
Button(
"playerSettings.graphics.nebulaQuality.cycle",
"Cycle Nebula Quality",
"aetheria.player_settings.graphics.nebula_quality.cycle")),
Metric(
"playerSettings.graphics.showAsteroids",
"Show Asteroids In Minimap",
graphics.ShowAsteroidsInMinimap ? "Enabled" : "Disabled"),
ButtonRow(
"playerSettings.graphics.showAsteroids.buttons",
Button(
"playerSettings.graphics.showAsteroids.toggle",
graphics.ShowAsteroidsInMinimap ? "Disable Minimap Asteroids" : "Enable Minimap Asteroids",
"aetheria.player_settings.graphics.show_asteroids.toggle"))))
},
Commands =
[
new EveCommandTemplate
{
Command = "aetheria.player_settings.refresh",
Label = "Refresh",
Transport = "cultmesh"
},
new EveCommandTemplate
{
Command = "aetheria.player_settings.gameplay.temperature_unit.cycle",
Label = "Cycle Temperature Unit",
Transport = "cultmesh"
},
new EveCommandTemplate
{
Command = "aetheria.player_settings.gameplay.significant_digits.decrement",
Label = "Digits -",
Transport = "cultmesh"
},
new EveCommandTemplate
{
Command = "aetheria.player_settings.gameplay.significant_digits.increment",
Label = "Digits +",
Transport = "cultmesh"
},
new EveCommandTemplate
{
Command = "aetheria.player_settings.graphics.nebula_quality.cycle",
Label = "Cycle Nebula Quality",
Transport = "cultmesh"
},
new EveCommandTemplate
{
Command = "aetheria.player_settings.graphics.show_asteroids.toggle",
Label = "Toggle Minimap Asteroids",
Transport = "cultmesh"
}
]
};
}
private static EveSurfaceComponent Metric(string id, string label, string value)
{
return Node(id, "metric", [("label", label), ("value", value)]);
}
private static EveSurfaceComponent Text(string id, string value)
{
return Node(id, "text", [("value", value)]);
}
private static EveSurfaceComponent Button(string id, string label, string command)
{
return Node(id, "control.button", [("label", label), ("command", command)]);
}
private static EveSurfaceComponent ButtonRow(string id, params EveSurfaceComponent[] children)
{
return Node(id, "row", [], children);
}
private static EveSurfaceComponent Row(string id, params (string Key, string Value)[] props)
{
return Node(id, "row", props);
}
private static EveSurfaceComponent Node(
string id,
string kind,
(string Key, string Value)[] props,
params EveSurfaceComponent[] children)
{
return new EveSurfaceComponent
{
Id = id,
Kind = kind,
Props = props.ToDictionary(prop => prop.Key, prop => prop.Value),
Children = children
};
}
}

View file

@ -64,6 +64,11 @@ public static class AetheriaProviderAdvertisementProjector
{
SurfaceId = AetheriaOperationsSurfaceProjector.SurfaceId,
Key = AetheriaOperationsSurfaceProjector.SurfaceKey
},
new EveProviderSurfaceRef
{
SurfaceId = AetheriaPlayerSettingsSurfaceProjector.SurfaceId,
Key = AetheriaPlayerSettingsSurfaceProjector.SurfaceKey
}
],
Commands =
@ -77,6 +82,36 @@ public static class AetheriaProviderAdvertisementProjector
{
Command = "aetheria.operations.refresh",
Summary = "Refresh operations projection"
},
new EveProviderCommandRef
{
Command = "aetheria.player_settings.refresh",
Summary = "Refresh player settings projection"
},
new EveProviderCommandRef
{
Command = "aetheria.player_settings.gameplay.temperature_unit.cycle",
Summary = "Cycle the typed player temperature unit"
},
new EveProviderCommandRef
{
Command = "aetheria.player_settings.gameplay.significant_digits.decrement",
Summary = "Decrease typed player significant digits"
},
new EveProviderCommandRef
{
Command = "aetheria.player_settings.gameplay.significant_digits.increment",
Summary = "Increase typed player significant digits"
},
new EveProviderCommandRef
{
Command = "aetheria.player_settings.graphics.nebula_quality.cycle",
Summary = "Cycle typed player nebula quality"
},
new EveProviderCommandRef
{
Command = "aetheria.player_settings.graphics.show_asteroids.toggle",
Summary = "Toggle typed player minimap asteroid visibility"
}
]
};

View file

@ -38,8 +38,12 @@ public static class AetheriaRuntimeCommitLogApplier
switch (command.Kind)
{
case "player_settings":
await node.PutPlayerSettingsAsync(
ToPlayerSettings(command.PlayerSettings ?? throw MissingPayload(command), command.CreatedAtUtc))
var settings = ToPlayerSettings(
command.PlayerSettings ?? throw MissingPayload(command),
command.CreatedAtUtc);
await node.PutPlayerSettingsAsync(settings).ConfigureAwait(false);
await node.PutPlayerSettingsSurfaceAsync(
AetheriaPlayerSettingsSurfaceProjector.Build(settings, command.CreatedAtUtc))
.ConfigureAwait(false);
report.AppliedPlayerSettings++;
break;

View file

@ -183,6 +183,16 @@ public sealed class AetheriaStateNode : IAsyncDisposable, IDisposable
return Database.GetAsync<EveSurfaceState>(new CultRecordKey(AetheriaOperationsSurfaceProjector.SurfaceKey));
}
public Task<CultRecordHandle<EveSurfaceState>> PutPlayerSettingsSurfaceAsync(EveSurfaceState surface)
{
return Database.PutAsync(new CultRecordKey(AetheriaPlayerSettingsSurfaceProjector.SurfaceKey), surface);
}
public Task<EveSurfaceState?> GetPlayerSettingsSurfaceAsync()
{
return Database.GetAsync<EveSurfaceState>(new CultRecordKey(AetheriaPlayerSettingsSurfaceProjector.SurfaceKey));
}
public Task<CultRecordHandle<EveProviderAdvertisementState>> PutProviderAdvertisementAsync(
EveProviderAdvertisementState advertisement)
{

View file

@ -54,4 +54,7 @@ public sealed class AetheriaEveCommandDrainStatus
[Key(14)]
public string Status { get; set; } = "ok";
[Key(15)]
public int AppliedPlayerSettingsCommands { get; set; }
}

View file

@ -53,8 +53,9 @@ Unity Eve surfaces also emit typed `gamecult.eve.command.v1` documents under
`GameData/aetheria-world.cc.eve.pending`. `AetheriaEveCommandBridge` is the
provider-owned acceptance organ for those commands: it validates the provider,
surface, and command template before running the narrow refresh handlers for
the catalog and operations surfaces. Renderer callbacks do not accept commands
or mutate game state locally.
the catalog and operations surfaces plus the typed player-settings mutation
handlers for gameplay/graphics Eve controls. Renderer callbacks do not accept
commands or mutate game state locally.
`AetheriaEveRuntimeBootstrap` mounts the `aetheria.operations` surface through a
runtime-created `UIDocument` after scene load, with environment and command-line
switches for diagnostics. UI Toolkit is now a live runtime lowering path, not
@ -319,9 +320,12 @@ allegiance edges so they cannot reclaim catalog lookup authority.
`Aetheria.State.Smoke` writes and reopens full typed player settings plus a
typed loadout template in addition to world, catalog, run state, zone state, and
an entity snapshot. It also writes and reopens `AetheriaRuntimeSession` and
checks that the Eve provider advertises the runtime-session schema. The run
smoke proves a typed run can reference a typed zone, the zone can preserve
an entity snapshot. It also writes and reopens `AetheriaRuntimeSession`, the
provider-owned `aetheria.player_settings` Eve surface, and player-settings Eve
commands that mutate typed significant-digit and minimap-asteroid settings
through the provider bridge. The smoke checks that the Eve provider advertises
the runtime-session schema and player-settings command surface. The run smoke
proves a typed run can reference a typed zone, the zone can preserve
orbit/body rows and reference typed entity snapshots, and entity snapshots can
preserve equipment slots, weapon groups, and simulation stat grids without
reviving `PlayerSettings.msgpack`, `.loadout`, or `.zone` serialization.
@ -374,17 +378,19 @@ dotnet run --project .\Economy.Server\Economy.Server.csproj -- --apply-pending-o
```
The server publishes `AetheriaRuntimeCommitDrainStatus`,
`AetheriaEveCommandDrainStatus`, and the `aetheria.operations` Eve surface after
drain attempts, so pending depth, accepted/applied/rejected counts, failures,
and timestamps are typed state rather than console-only status. It also
`AetheriaEveCommandDrainStatus`, the `aetheria.operations` Eve surface, and the
typed `aetheria.player_settings` Eve surface after drain attempts, so pending
depth, accepted/applied/rejected counts, failures, timestamps, and player
settings controls are typed state rather than console-only status. It also
publishes `gamecult.eve.provider_advertisement.v1` for the `aetheria` provider,
advertising the catalog and operations surfaces plus the typed schemas witnessed
by the local `.cc` state file.
advertising the catalog, operations, and player-settings surfaces plus the
typed schemas witnessed by the local `.cc` state file.
`Aetheria.State.ApplyPending` is the smaller local operator applicator for
queued Unity runtime commits and Eve commands when the server host is not being
used. It also republishes the typed drain status, operations surface, and
provider advertisement after applying pending files:
used. It also republishes the typed drain status, operations surface,
player-settings surface, and provider advertisement after applying pending
files:
```powershell
dotnet run --project .\Aetheria.State.ApplyPending\Aetheria.State.ApplyPending.csproj -- .