diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index da410d341..1a7f52912 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -2895,7 +2895,7 @@ static void RequireEveRuntimeBootstrap(string root) "MountSurface(string statePath, EveSurfaceDocument surface)", "AetheriaEveUnitySurfaceHost.Render(", "AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(statePath, request, out var daemonEnvelope)", - "AetheriaRuntimeEveCommands.TrySendKnownSurfaceCommand(" + "SubmitKnownSurfaceCommandAsync(" }; var missingPresenterSymbols = requiredPresenterSymbols .Where(symbol => !presenter.Contains(symbol, StringComparison.Ordinal)) @@ -2923,7 +2923,7 @@ static void RequireEveRuntimeBootstrap(string root) "AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(statePath, request, out var daemonEnvelope)", StringComparison.Ordinal); var eveSubmitIndex = presenter.IndexOf( - "AetheriaRuntimeEveCommands.TrySendKnownSurfaceCommand(", + "SubmitKnownSurfaceCommandAsync(", StringComparison.Ordinal); if (daemonSubmitIndex < 0 || eveSubmitIndex < 0 || daemonSubmitIndex > eveSubmitIndex) { @@ -3160,7 +3160,7 @@ static void RequireMainMenuSettingsCommands(string root) { "SendKnownAetheriaEveCommand(request, \"player-settings\")", "AetheriaRuntimeMainMenuCommandKind.PlayerSettingsCommand", - "AetheriaRuntimeEveCommands.TrySendKnownSurfaceCommand(", + "SubmitKnownSurfaceCommandAsync(request, \"unity-main-menu\")", "stateBoot.StateFilePath", "\"unity-main-menu\"" }; @@ -3956,7 +3956,7 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root) var requiredActionGameManagerSymbols = new[] { "SendRuntimeInputSettingsCommand(", - "AetheriaRuntimeEveCommands.TrySendInputSettingsCommand", + "SubmitInputSettingsCommandAsync(", "AetheriaRuntimeEveCommandKind.SetBindingOverride", "AetheriaRuntimeEveCommandKind.SetActionBarEnabled" }; @@ -6830,7 +6830,7 @@ static void RequireVerseSettingsShellAndBridge(string root) "AetheriaRuntimeMainMenuCommandKind.VerseHostCommand", "RequestClientTargetCommand(request)", "SendKnownAetheriaEveCommand(request, \"Verse-host\")", - "AetheriaRuntimeEveCommands.TrySendKnownSurfaceCommand(", + "SubmitKnownSurfaceCommandAsync(request, \"unity-main-menu\")", "AetheriaState.At(ActionGameManager.GameDataDirectory)", ".ClientTarget", "AetheriaRuntimeClientTargetSurfaceCommands.TryRequest(" @@ -8218,6 +8218,7 @@ static void RequireTypedEveCommandBodies(string root) { var eveCommandDocumentPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeEveCommandDocument.cs"); var eveCommandClientPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeEveCommandClient.cs"); + var verseClientPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeVerseClient.cs"); var runtimeCommandPortPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeCommandPort.cs"); var eveCommandBridgePath = Path.Combine(root, "Aetheria.State", "AetheriaEveCommandBridge.cs"); var stateNodePath = Path.Combine(root, "Aetheria.State", "AetheriaStateNode.cs"); @@ -8226,7 +8227,7 @@ static void RequireTypedEveCommandBodies(string root) var mainMenuPath = Path.Combine(root, "Assets", "Scripts", "UI", "MainMenu.cs"); var evePresenterPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.eve-runtime", "Runtime", "AetheriaEveSurfacePresenter.cs"); - var requiredFiles = new[] { eveCommandDocumentPath, eveCommandClientPath, runtimeCommandPortPath, eveCommandBridgePath, stateNodePath, documentRegistryPath, actionGameManagerPath, mainMenuPath, evePresenterPath }; + var requiredFiles = new[] { eveCommandDocumentPath, eveCommandClientPath, verseClientPath, runtimeCommandPortPath, eveCommandBridgePath, stateNodePath, documentRegistryPath, actionGameManagerPath, mainMenuPath, evePresenterPath }; var missingFiles = requiredFiles .Where(path => !File.Exists(path)) .Select(path => Path.GetRelativePath(root, path)) @@ -8240,6 +8241,7 @@ static void RequireTypedEveCommandBodies(string root) var eveCommandDocument = File.ReadAllText(eveCommandDocumentPath); var eveCommandClient = File.ReadAllText(eveCommandClientPath); + var verseClient = File.ReadAllText(verseClientPath); var normalizedEveCommandClient = eveCommandClient.Replace("\r\n", "\n", StringComparison.Ordinal); var runtimeCommandPort = File.ReadAllText(runtimeCommandPortPath); var eveCommandBridge = File.ReadAllText(eveCommandBridgePath); @@ -8333,12 +8335,12 @@ static void RequireTypedEveCommandBodies(string root) "command.PlayerSettings.PlayerName", "command.InputSettings.ActionName", "command.InputSettings.InputSystemPath", - "AetheriaRuntimeEveCommands.TrySendInputSettingsCommand(", - "AetheriaRuntimeEveCommands.TrySendLoadoutTemplateCommand(", - "AetheriaRuntimeEveCommands.TrySendKnownSurfaceCommand(" + "SubmitInputSettingsCommandAsync(", + "SubmitLoadoutTemplateCommandAsync(", + "SubmitKnownSurfaceCommandAsync(" }; var mainMenu = File.ReadAllText(mainMenuPath); - var typedCommandSources = eveCommandClient + "\n" + runtimeCommandPort + "\n" + eveCommandBridge + "\n" + stateNode + "\n" + documentRegistry + "\n" + actionGameManager + "\n" + mainMenu + "\n" + evePresenter; + var typedCommandSources = eveCommandClient + "\n" + verseClient + "\n" + runtimeCommandPort + "\n" + eveCommandBridge + "\n" + stateNode + "\n" + documentRegistry + "\n" + actionGameManager + "\n" + mainMenu + "\n" + evePresenter; if (typedCommandSources.Contains("DeleteEveCommandAsync(", StringComparison.Ordinal)) { throw new InvalidOperationException( @@ -8362,6 +8364,30 @@ static void RequireTypedEveCommandBodies(string root) string.Join(", ", missingTypedCommandSymbols)); } + var forbiddenUnityEveCommandSubmitSymbols = new[] + { + "AetheriaRuntimeEveCommands.TrySendInputSettingsCommand", + "AetheriaRuntimeEveCommands.TrySendLoadoutTemplateCommand", + "AetheriaRuntimeEveCommands.TrySendKnownSurfaceCommand" + }; + var unityCommandSources = new Dictionary + { + [actionGameManagerPath] = actionGameManager, + [mainMenuPath] = mainMenu, + [evePresenterPath] = evePresenter + }; + var legacyUnityCommandHits = unityCommandSources + .SelectMany(entry => forbiddenUnityEveCommandSubmitSymbols + .Where(symbol => entry.Value.Contains(symbol, StringComparison.Ordinal)) + .Select(symbol => $"{Path.GetRelativePath(root, entry.Key)} -> {symbol}")) + .ToArray(); + if (legacyUnityCommandHits.Length > 0) + { + throw new InvalidOperationException( + "Unity-facing shells still submit Eve commands through legacy helper ports instead of AetheriaRuntimeVerseClient: " + + string.Join("; ", legacyUnityCommandHits)); + } + var unityNamedRuntimeSources = new Dictionary { ["Aetheria.State.Daemon"] = File.Exists(Path.Combine(root, "Aetheria.State.Daemon", "Program.cs")) @@ -11423,7 +11449,7 @@ static void RequireInventoryLoadoutSaveRequestAuthority(string root) "ProjectCargoBays(IEnumerable bays)", "SendRuntimeLoadoutTemplateCommand(loadout", "private static void SendRuntimeLoadoutTemplateCommand(", - "AetheriaRuntimeEveCommands.TrySendLoadoutTemplateCommand", + "SubmitLoadoutTemplateCommandAsync(loadout, clientId)", }; var missingActionSymbols = requiredActionSymbols .Where(symbol => !actionGameManager.Contains(symbol, StringComparison.Ordinal)) diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index f70506694..158d8100e 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -126,19 +126,12 @@ public class ActionGameManager : MonoBehaviour { try { - if (!AetheriaRuntimeEveCommands.TrySendInputSettingsCommand( - RuntimeStateFilePath, - command, - body, - clientId, - out var submitted, - out var error)) - { - Debug.LogError($"Failed to submit Aetheria {label} Eve command: {error}"); - return; - } + var submitted = ResolveRuntimeVerseClient(RuntimeStateFilePath) + .SubmitInputSettingsCommandAsync(command, body, clientId) + .GetAwaiter() + .GetResult(); - Debug.Log($"Submitted Aetheria {label} Eve command: {submitted!.CommandId}"); + Debug.Log($"Submitted Aetheria {label} Eve command: {submitted.CommandId}"); } catch (Exception ex) { @@ -1101,18 +1094,12 @@ public class ActionGameManager : MonoBehaviour { try { - if (!AetheriaRuntimeEveCommands.TrySendLoadoutTemplateCommand( - RuntimeStateFilePath, - loadout, - clientId, - out var submitted, - out var error)) - { - Debug.LogError($"Failed to submit Aetheria {label} Eve command: {error}"); - return; - } + var submitted = ResolveRuntimeVerseClient(RuntimeStateFilePath) + .SubmitLoadoutTemplateCommandAsync(loadout, clientId) + .GetAwaiter() + .GetResult(); - Debug.Log($"Submitted Aetheria {label} Eve command: {submitted!.CommandId}"); + Debug.Log($"Submitted Aetheria {label} Eve command: {submitted.CommandId}"); } catch (Exception ex) { diff --git a/Assets/Scripts/UI/MainMenu.cs b/Assets/Scripts/UI/MainMenu.cs index 605d95ca6..19110a36c 100644 --- a/Assets/Scripts/UI/MainMenu.cs +++ b/Assets/Scripts/UI/MainMenu.cs @@ -418,7 +418,7 @@ public class MainMenu : MonoBehaviour } } - private static void SendKnownAetheriaEveCommand( + private void SendKnownAetheriaEveCommand( EveSurfaceCommandRequest request, string label) { @@ -431,18 +431,12 @@ public class MainMenu : MonoBehaviour try { - if (!AetheriaRuntimeEveCommands.TrySendKnownSurfaceCommand( - stateBoot.StateFilePath, - request, - "unity-main-menu", - out var submitted, - out var error)) - { - Debug.LogError($"Failed to submit Aetheria {label} Eve command: {error}"); - return; - } + var submitted = ResolveVerseClient(stateBoot) + .SubmitKnownSurfaceCommandAsync(request, "unity-main-menu") + .GetAwaiter() + .GetResult(); - Debug.Log($"Submitted Aetheria {label} Eve command: {submitted!.CommandId}"); + Debug.Log($"Submitted Aetheria {label} Eve command: {submitted.CommandId}"); } catch (Exception ex) { diff --git a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveSurfacePresenter.cs b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveSurfacePresenter.cs index 7229d7367..a9c888387 100644 --- a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveSurfacePresenter.cs +++ b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveSurfacePresenter.cs @@ -213,7 +213,7 @@ namespace GameCult.Aetheria.EveRuntime _mountedSurfaceUpdatedAtUtc = surface.UpdatedAtUtc ?? ""; } - private static void EmitCommand(string statePath, EveSurfaceCommandRequest request) + private void EmitCommand(string statePath, EveSurfaceCommandRequest request) { if (AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(statePath, request, out var daemonEnvelope)) { @@ -222,20 +222,23 @@ namespace GameCult.Aetheria.EveRuntime return; } - if (!AetheriaRuntimeEveCommands.TrySendKnownSurfaceCommand( - statePath, - request, - string.IsNullOrWhiteSpace(request.ClientId) ? "unity-uitoolkit" : request.ClientId, - out var envelope, - out var error)) + try + { + var envelope = ResolveVerseClient(statePath) + .SubmitKnownSurfaceCommandAsync( + request, + string.IsNullOrWhiteSpace(request.ClientId) ? "unity-uitoolkit" : request.ClientId) + .GetAwaiter() + .GetResult(); + + Debug.Log( + $"Submitted Eve command for CultMesh bridge: {envelope.ProviderId}/{envelope.SurfaceId}/{envelope.Command} {envelope.CommandId}"); + } + catch (Exception ex) { Debug.LogWarning( - $"Ignored or failed Aetheria Eve command: {request.ProviderId}/{request.SurfaceId}/{request.Command}: {error}"); - return; + $"Ignored or failed Aetheria Eve command: {request.ProviderId}/{request.SurfaceId}/{request.Command}: {ex}"); } - - Debug.Log( - $"Submitted Eve command for CultMesh bridge: {envelope!.ProviderId}/{envelope.SurfaceId}/{envelope.Command} {envelope.CommandId}"); } private void OnDisable() diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs index 404d91877..eb1f43d42 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Aetheria.State.Documents; using GameCult.Caching; using GameCult.Caching.MessagePack; +using GameCult.Eve.Surface; using GameCult.Mesh; using GameCult.Networking; using R3; @@ -496,6 +497,49 @@ namespace GameCult.Aetheria.State.Verse return AetheriaRuntimeEveCommandClient.ToEnvelope(command); } + public Task SubmitInputSettingsCommandAsync( + AetheriaRuntimeEveCommandKind command, + AetheriaRuntimeInputSettingsCommandBody body, + string clientId, + bool flush = true) + { + ThrowIfDisposed(); + return SubmitEveCommandAsync( + AetheriaRuntimeEveCommandClient.ToDocument( + AetheriaRuntimeEveCommandClient.CreateInputSettingsCommand(command, body, clientId)), + flush); + } + + public Task SubmitLoadoutTemplateCommandAsync( + AetheriaRuntimeLoadoutTemplateCommit loadoutTemplate, + string clientId, + bool flush = true) + { + ThrowIfDisposed(); + return SubmitEveCommandAsync( + AetheriaRuntimeEveCommandClient.ToDocument( + AetheriaRuntimeEveCommandClient.CreateLoadoutTemplateCommand(loadoutTemplate, clientId)), + flush); + } + + public Task SubmitKnownSurfaceCommandAsync( + EveSurfaceCommandRequest request, + string clientId, + bool flush = true) + { + ThrowIfDisposed(); + if (!AetheriaRuntimeEveCommandClient.TryCreateKnownSurfaceCommand(request, out var envelope)) + { + throw new InvalidOperationException( + $"Unknown Aetheria Eve surface command: {request?.ProviderId}/{request?.SurfaceId}/{request?.Command}"); + } + + var document = AetheriaRuntimeEveCommandClient.ToDocument(envelope!); + if (!string.IsNullOrWhiteSpace(clientId)) + document.ClientId = clientId; + return SubmitEveCommandAsync(document, flush); + } + public Task FlushAsync(bool soft = false) { ThrowIfDisposed();