diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 0f02e2f59..ffd32ebe6 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -2212,7 +2212,8 @@ static void RequireEveRuntimeBootstrap(string root) "request.ProviderId, \"aetheria.daemon\"", "AetheriaRuntimeStateReader.TryReadObservedDaemonState(stateFilePath, out var observed)", "new AetheriaRuntimeDaemonOperationClient(", - "client.TrySendCommandKind(kind, observed, out envelope, out _)" + "TrySubmitKnownCommand(client, observed, kind, out envelope)", + "AetheriaRuntimeDaemonCommandKinds.SensorPing => client.SensorPing(observed)" }; var missingDaemonSurfaceCommandSymbols = requiredDaemonSurfaceCommandSymbols .Where(symbol => !daemonSurfaceCommands.Contains(symbol, StringComparison.Ordinal)) @@ -2248,6 +2249,12 @@ static void RequireEveRuntimeBootstrap(string root) throw new InvalidOperationException( "Daemon Eve surface command routing still calls the generic daemon submitter instead of the typed daemon operation client."); } + + if (daemonSurfaceCommands.Contains("TrySendCommandKind(", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Daemon Eve surface command routing still uses a generic command-kind submission back door instead of explicit typed operations."); + } } static void RequireNoRendererLocalConsole(string root) @@ -5907,7 +5914,7 @@ static void RequireTypedDaemonCommandPayloads(string root) var requiredClientSymbols = new[] { - "public bool TrySendCommandKind(", + "private AetheriaRuntimeDaemonCommandEnvelope Send(AetheriaRuntimeDaemonCommandDocument command)", "ReadObservedDaemonCommands()", "Func submit", "return Send((client, observed) => client.SetTarget(observed, targetEntityKey));", @@ -6019,6 +6026,7 @@ static void RequireTypedDaemonCommandPayloads(string root) var forbiddenClientDocumentBuilderSymbols = new[] { + "TrySendCommandKind(", "Action", "configure?.Invoke(command)", "Send(AetheriaRuntimeDaemonCommandKinds" diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index 8fe2ae778..67cccc881 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -1032,6 +1032,37 @@ public class DaemonRuntimeDocumentTests Assert.IsEmpty(envelope.Path); } + [Test] + public void DaemonEveSurfaceCommandRejectsUnsupportedArgumentlessOperation() + { + var statePath = Path.Combine( + Path.GetTempPath(), + "aetheria-daemon-surface-command-tests", + Path.GetRandomFileName(), + "state.cc"); + var frame = AetheriaRuntimeDaemonFrameDocument.Create( + new AetheriaRuntimeRunCheckpointCommit + { + CurrentEntityKey = "entity:surface-player" + }, + "aetheria-daemon", + "session-surface-command", + 78, + 1.5, + 0.02); + AetheriaRuntimeDaemonFrameStore.PublishFrame(statePath, frame); + var request = new EveSurfaceCommandRequest( + "aetheria.daemon", + AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId, + "aetheria.daemon.commands.TransferCargoItem", + new Dictionary(StringComparer.Ordinal), + DateTimeOffset.UtcNow, + "unity-uitoolkit"); + + Assert.IsFalse(AetheriaRuntimeDaemonSurfaceCommands.TrySubmit(statePath, request, out var envelope)); + Assert.IsNull(envelope); + } + [Test] public void DaemonOperationsMovesTargetSelectionIntoDaemonState() { diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs index 3db96d24f..2f024349e 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs @@ -79,7 +79,7 @@ namespace GameCult.Aetheria.State.Verse Row( "aetheria.daemon.game.commands.primary", CommandButton("aetheria.daemon.game.commands.move", "Move", AetheriaRuntimeDaemonCommandKinds.SetMoveVector), - CommandButton("aetheria.daemon.game.commands.target", "Set Target", AetheriaRuntimeDaemonCommandKinds.SetTarget), + CommandButton("aetheria.daemon.game.commands.target", "Target Nearest", AetheriaRuntimeDaemonCommandKinds.TargetNearest), CommandButton("aetheria.daemon.game.commands.fire", "Fire", AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup), CommandButton("aetheria.daemon.game.commands.ping", "Sensor Ping", AetheriaRuntimeDaemonCommandKinds.SensorPing)))), Array.Empty()), diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs index f1244a2b6..f16667f42 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs @@ -23,20 +23,6 @@ namespace GameCult.Aetheria.State.Verse public string ClientId { get; } public string SessionId { get; } - public bool TrySendCommandKind( - AetheriaRuntimeDaemonCommandKinds kind, - AetheriaRuntimeObservedDaemonState? observed, - out AetheriaRuntimeDaemonCommandEnvelope? envelope, - out string error) - { - var command = Create(kind, observed); - if (TrySend(command, out envelope, out error)) - return true; - - envelope = ToEnvelope(command); - return false; - } - private AetheriaRuntimeDaemonCommandEnvelope Send(AetheriaRuntimeDaemonCommandDocument command) { if (!TrySend(command, out var envelope, out var error)) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs index 7c1fc6b57..e8398524e 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommands.cs @@ -27,12 +27,47 @@ namespace GameCult.Aetheria.State.Verse stateFilePath, string.IsNullOrWhiteSpace(request.ClientId) ? "unity-uitoolkit" : request.ClientId, observed?.Frame.SessionId ?? "local"); - if (client.TrySendCommandKind(kind, observed, out envelope, out _)) - { - return true; - } + return TrySubmitKnownCommand(client, observed, kind, out envelope); + } - return true; + private static bool TrySubmitKnownCommand( + AetheriaRuntimeDaemonOperationClient client, + AetheriaRuntimeObservedDaemonState? observed, + AetheriaRuntimeDaemonCommandKinds kind, + out AetheriaRuntimeDaemonCommandEnvelope? envelope) + { + envelope = null; + if (client == null) + return false; + + try + { + envelope = kind switch + { + AetheriaRuntimeDaemonCommandKinds.ClearTarget => client.ClearTarget(observed), + AetheriaRuntimeDaemonCommandKinds.TargetNearest => client.TargetNearest(observed), + AetheriaRuntimeDaemonCommandKinds.TargetNext => client.TargetNext(observed), + AetheriaRuntimeDaemonCommandKinds.TargetPrevious => client.TargetPrevious(observed), + AetheriaRuntimeDaemonCommandKinds.SetMoveVector => client.SetMoveVector(observed, 0.0, 1.0), + AetheriaRuntimeDaemonCommandKinds.SetLookDirection => client.SetLookDirection(observed, 0.0, 1.0, 0.0), + AetheriaRuntimeDaemonCommandKinds.SetTractorPower => client.SetTractorPower(observed, 1.0), + AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup => client.FireWeaponGroup(observed, 0), + AetheriaRuntimeDaemonCommandKinds.SetWeaponGroupActive => client.SetWeaponGroupActive(observed, 0, true), + AetheriaRuntimeDaemonCommandKinds.SensorPing => client.SensorPing(observed), + AetheriaRuntimeDaemonCommandKinds.SetHeatsinksEnabled => client.SetHeatsinksEnabled(observed, true), + AetheriaRuntimeDaemonCommandKinds.SetOverrideShutdown => client.SetOverrideShutdown(observed, true), + AetheriaRuntimeDaemonCommandKinds.ToggleShieldEnabled => client.ToggleShieldEnabled(observed), + AetheriaRuntimeDaemonCommandKinds.DockNearest => client.DockNearest(observed, 0.0), + AetheriaRuntimeDaemonCommandKinds.Undock => client.Undock(observed), + _ => null + }; + return envelope != null; + } + catch (InvalidOperationException) + { + envelope = null; + return false; + } } private static bool TryResolveKind(EveSurfaceCommandRequest request, out AetheriaRuntimeDaemonCommandKinds kind)