diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 090b29bc8..cf43d47dc 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -4972,12 +4972,12 @@ static void RequireRuntimeMenuTabsUseEveSurface(string root) "public const string Continue = \"aetheria.runtime_menu.local_story.continue\"", "ChoiceCommandFor(int choiceIndex)", "public static AetheriaRuntimeSurfaceDocument Build(", - "private static AetheriaRuntimeLocalStorySurfaceState ComposeState(", + "var storyBody = string.IsNullOrWhiteSpace(body) ? \"...\" : body.Trim()", + "var orderedChoices = (choices ?? Array.Empty())", "public enum AetheriaRuntimeLocalStoryCommandKind", "public readonly struct AetheriaRuntimeLocalStoryCommand", "public static class AetheriaRuntimeLocalStorySurfaceCommands", - "AetheriaRuntimeLocalStoryChoiceState", - "AetheriaRuntimeLocalStorySurfaceState" + "AetheriaRuntimeLocalStoryChoiceState" }; var missingLocalStoryBuilderSymbols = requiredLocalStoryBuilderSymbols .Where(symbol => !localStorySurfaceBuilder.Contains(symbol, StringComparison.Ordinal)) @@ -4989,6 +4989,14 @@ static void RequireRuntimeMenuTabsUseEveSurface(string root) string.Join(", ", missingLocalStoryBuilderSymbols)); } + if (localStorySurfaceBuilder.Contains("AetheriaRuntimeLocalStorySurfaceState", StringComparison.Ordinal) || + localStorySurfaceBuilder.Contains("ComposeState(", StringComparison.Ordinal) || + localStorySurfaceBuilder.Contains("public static AetheriaRuntimeLocalStorySurfaceState Project(", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Runtime local story composition must emit the typed surface document directly; do not rebuild a shadow SurfaceState projection layer."); + } + var requiredBuilderSymbols = new[] { "public static class AetheriaRuntimeMenuTabsSurfaceBuilder", diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeLocalStorySurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeLocalStorySurfaceBuilder.cs index 5b63896b6..00cb34d4a 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeLocalStorySurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeLocalStorySurfaceBuilder.cs @@ -17,32 +17,6 @@ namespace GameCult.Aetheria.State.Verse public string Label { get; } } - public sealed class AetheriaRuntimeLocalStorySurfaceState - { - public AetheriaRuntimeLocalStorySurfaceState( - string locationLabel, - string currentPath, - string body, - bool canContinue, - IReadOnlyList choices, - string updatedAtUtc) - { - LocationLabel = locationLabel ?? ""; - CurrentPath = currentPath ?? ""; - Body = body ?? ""; - CanContinue = canContinue; - Choices = choices ?? Array.Empty(); - UpdatedAtUtc = updatedAtUtc ?? ""; - } - - public string LocationLabel { get; } - public string CurrentPath { get; } - public string Body { get; } - public bool CanContinue { get; } - public IReadOnlyList Choices { get; } - public string UpdatedAtUtc { get; } - } - public static class AetheriaRuntimeLocalStorySurfaceBuilder { public const string SurfaceId = "aetheria.runtime_menu.local_story"; @@ -63,46 +37,15 @@ namespace GameCult.Aetheria.State.Verse string updatedAtUtc, long version = 1) { - return Build( - ComposeState( - locationLabel, - currentPath, - body, - canContinue, - choices, - updatedAtUtc), - version); - } - - private static AetheriaRuntimeLocalStorySurfaceState ComposeState( - string locationLabel, - string currentPath, - string body, - bool canContinue, - IEnumerable choices, - string updatedAtUtc) - { - return new AetheriaRuntimeLocalStorySurfaceState( - locationLabel, - currentPath, - string.IsNullOrWhiteSpace(body) ? "..." : body.Trim(), - canContinue, - (choices ?? Array.Empty()) - .Where(choice => choice != null) - .OrderBy(choice => choice.Index) - .ToArray(), - updatedAtUtc); - } - - public static AetheriaRuntimeSurfaceDocument Build( - AetheriaRuntimeLocalStorySurfaceState state, - long version = 1) - { - state ??= ComposeState("", "", "", false, Array.Empty(), ""); + var storyBody = string.IsNullOrWhiteSpace(body) ? "..." : body.Trim(); + var orderedChoices = (choices ?? Array.Empty()) + .Where(choice => choice != null) + .OrderBy(choice => choice.Index) + .ToArray(); var commands = new List(); var controls = new List(); - if (state.CanContinue) + if (canContinue) { commands.Add(new AetheriaRuntimeSurfaceCommandTemplate( Continue, @@ -111,7 +54,7 @@ namespace GameCult.Aetheria.State.Verse controls.Add(Button($"{SurfaceId}.continue", "Continue", Continue)); } - foreach (var choice in state.Choices) + foreach (var choice in orderedChoices) { var command = ChoiceCommandFor(choice.Index); commands.Add(new AetheriaRuntimeSurfaceCommandTemplate( @@ -125,9 +68,9 @@ namespace GameCult.Aetheria.State.Verse { Card( $"{SurfaceId}.card", - string.IsNullOrWhiteSpace(state.LocationLabel) ? "Local" : state.LocationLabel, - Text($"{SurfaceId}.body", state.Body), - Metric($"{SurfaceId}.path", "Path", string.IsNullOrWhiteSpace(state.CurrentPath) ? "root" : state.CurrentPath)) + string.IsNullOrWhiteSpace(locationLabel) ? "Local" : locationLabel, + Text($"{SurfaceId}.body", storyBody), + Metric($"{SurfaceId}.path", "Path", string.IsNullOrWhiteSpace(currentPath) ? "root" : currentPath)) }; if (controls.Count > 0) children.Add(ButtonColumn($"{SurfaceId}.controls", controls.ToArray())); @@ -137,7 +80,7 @@ namespace GameCult.Aetheria.State.Verse providerKind: "runtime.menu", title: "Local Story", version: version, - updatedAtUtc: state.UpdatedAtUtc, + updatedAtUtc: updatedAtUtc ?? "", surface: new AetheriaRuntimeSurfaceTree( SurfaceId, Node(