diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 24b58b77b..0f252a092 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -9100,9 +9100,9 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) "TryRequestDaemonUndock()", "TryRequestDaemonInteract()", "TryRequestDaemonTowToStation()", - "observer.Operations.DockNearest(Settings.GameplaySettings.DockingDistance)", + "observer.Operations.DockNearest()", "observer.Operations.Undock()", - "observer.Operations.Interact(", + "observer.Operations.Interact()", "observer.Operations.TowToStation(", "ResolveObservedEntityZoneIndex(TowingStation)", "TowingStation.CultPositionXZ.x", @@ -9187,9 +9187,11 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) "AetheriaRuntimeDaemonCommandKinds.Interact", "public AetheriaRuntimeDaemonCommandEnvelope DockNearest(", "public AetheriaRuntimeDaemonCommandEnvelope Interact(", - "ApplyDockNearestIntent(run, command, context.Intents)", - "ApplyInteractIntent(run, command, context.Intents)", - "TryFindNearestDockTarget(run, actorKey, command.ScalarValue, out var targetKey)", + "ApplyDockNearestIntent(run, command, context.Intents, context.DockingDistance)", + "context.WormholeExitRadius", + "AetheriaRuntimeDaemonOperationContext.DefaultDockingDistance", + "AetheriaRuntimeDaemonOperationContext.DefaultWormholeExitRadius", + "ResolveInteractionDistance(command.ScalarValue, defaultDockingDistance)", "TryFindNearestWormholeTarget(" }; var daemonDockNearestSources = daemonDocuments + "\n" + daemonOperationClient + "\n" + daemonOperationsSource; @@ -9203,6 +9205,19 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) string.Join(", ", missingDaemonDockNearestSymbols)); } + var unityOwnedInteractionTuningHits = FindMethodScopedLineHits( + actionGameManager, + new[] { "Settings.GameplaySettings.DockingDistance", "Settings.GameplaySettings.WormholeExitRadius" }) + .Where(hit => hit.MethodName == "TryRequestDaemonDock" || hit.MethodName == "TryRequestDaemonInteract") + .Select(hit => $"ActionGameManager.cs:{hit.LineNumber}: {hit.Line.Trim()}") + .ToArray(); + if (unityOwnedInteractionTuningHits.Length > 0) + { + throw new InvalidOperationException( + "Unity interaction requests still carry GameSettings tuning instead of semantic daemon operations: " + + string.Join("; ", unityOwnedInteractionTuningHits)); + } + var movementLocalAuthorityHits = FindMethodScopedLineHits( actionGameManager, new[] { "CurrentEntity?.Parent != null" }) diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index cd088e19f..3f0ad3232 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -2248,9 +2248,7 @@ public class ActionGameManager : MonoBehaviour try { - observer.Operations.Interact( - Settings.GameplaySettings.DockingDistance, - Settings.GameplaySettings.WormholeExitRadius); + observer.Operations.Interact(); return true; } catch (Exception ex) @@ -4105,7 +4103,7 @@ public class ActionGameManager : MonoBehaviour try { - observer.Operations.DockNearest(Settings.GameplaySettings.DockingDistance); + observer.Operations.DockNearest(); return true; } catch (Exception ex) diff --git a/Assets/Scripts/Gameplay/AetheriaDaemonOperations.cs b/Assets/Scripts/Gameplay/AetheriaDaemonOperations.cs index 44f9200d0..750bda4c6 100644 --- a/Assets/Scripts/Gameplay/AetheriaDaemonOperations.cs +++ b/Assets/Scripts/Gameplay/AetheriaDaemonOperations.cs @@ -200,9 +200,9 @@ public sealed class AetheriaDaemonOperations return Send((client, observed) => client.Dock(observed, targetEntityKey)); } - public AetheriaRuntimeDaemonCommandEnvelope DockNearest(double maxDistance) + public AetheriaRuntimeDaemonCommandEnvelope DockNearest() { - return Send((client, observed) => client.DockNearest(observed, maxDistance)); + return Send((client, observed) => client.DockNearest(observed)); } public AetheriaRuntimeDaemonCommandEnvelope Undock() @@ -210,9 +210,9 @@ public sealed class AetheriaDaemonOperations return Send((client, observed) => client.Undock(observed)); } - public AetheriaRuntimeDaemonCommandEnvelope Interact(double dockDistance, double wormholeDistance) + public AetheriaRuntimeDaemonCommandEnvelope Interact() { - return Send((client, observed) => client.Interact(observed, dockDistance, wormholeDistance)); + return Send((client, observed) => client.Interact(observed)); } public AetheriaRuntimeDaemonCommandEnvelope SetDockedCurrentShip(string targetEntityKey) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs index d12244601..88aefa2b7 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs @@ -359,12 +359,9 @@ namespace GameCult.Aetheria.State.Verse return Send(command); } - public AetheriaRuntimeDaemonCommandEnvelope DockNearest( - AetheriaRuntimeObservedDaemonState? observed, - double maxDistance) + public AetheriaRuntimeDaemonCommandEnvelope DockNearest(AetheriaRuntimeObservedDaemonState? observed) { var command = Create(AetheriaRuntimeDaemonCommandKinds.DockNearest, observed); - command.ScalarValue = maxDistance; return Send(command); } @@ -373,14 +370,9 @@ namespace GameCult.Aetheria.State.Verse return Send(Create(AetheriaRuntimeDaemonCommandKinds.Undock, observed)); } - public AetheriaRuntimeDaemonCommandEnvelope Interact( - AetheriaRuntimeObservedDaemonState? observed, - double dockDistance, - double wormholeDistance) + public AetheriaRuntimeDaemonCommandEnvelope Interact(AetheriaRuntimeObservedDaemonState? observed) { var command = Create(AetheriaRuntimeDaemonCommandKinds.Interact, observed); - command.ScalarValue = dockDistance; - command.PositionX = wormholeDistance; return Send(command); } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs index 5456b344b..e34843344 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs @@ -29,10 +29,17 @@ namespace GameCult.Aetheria.State.Verse public sealed class AetheriaRuntimeDaemonOperationContext { + public const double DefaultDockingDistance = 25.0; + public const double DefaultWormholeExitRadius = 50.0; + public IReadOnlyList LoadoutTemplates { get; set; } = Array.Empty(); public AetheriaRuntimeDaemonIntentState Intents { get; set; } = new AetheriaRuntimeDaemonIntentState(); + + public double DockingDistance { get; set; } = AetheriaRuntimeDaemonOperationContext.DefaultDockingDistance; + + public double WormholeExitRadius { get; set; } = AetheriaRuntimeDaemonOperationContext.DefaultWormholeExitRadius; } public static class AetheriaRuntimeDaemonOperations @@ -160,11 +167,16 @@ namespace GameCult.Aetheria.State.Verse case AetheriaRuntimeDaemonCommandKinds.Dock: return ApplyDockIntent(run, command, context.Intents); case AetheriaRuntimeDaemonCommandKinds.DockNearest: - return ApplyDockNearestIntent(run, command, context.Intents); + return ApplyDockNearestIntent(run, command, context.Intents, context.DockingDistance); case AetheriaRuntimeDaemonCommandKinds.Undock: return ApplyUndockIntent(run, command, context.Intents); case AetheriaRuntimeDaemonCommandKinds.Interact: - return ApplyInteractIntent(run, command, context.Intents); + return ApplyInteractIntent( + run, + command, + context.Intents, + context.DockingDistance, + context.WormholeExitRadius); case AetheriaRuntimeDaemonCommandKinds.EnterWormhole: return ApplyEnterWormholeIntent(run, command, context.Intents); case AetheriaRuntimeDaemonCommandKinds.TowToStation: @@ -1134,11 +1146,16 @@ namespace GameCult.Aetheria.State.Verse private static bool ApplyDockNearestIntent( AetheriaRuntimeRunCheckpointCommit run, AetheriaRuntimeDaemonCommandDocument command, - AetheriaRuntimeDaemonIntentState intents) + AetheriaRuntimeDaemonIntentState intents, + double defaultDockingDistance) { var actorKey = ResolveActorEntityKey(run, command); if (string.IsNullOrWhiteSpace(actorKey) || - !TryFindNearestDockTarget(run, actorKey, command.ScalarValue, out var targetKey)) + !TryFindNearestDockTarget( + run, + actorKey, + ResolveInteractionDistance(command.ScalarValue, defaultDockingDistance), + out var targetKey)) { return false; } @@ -1170,7 +1187,9 @@ namespace GameCult.Aetheria.State.Verse private static bool ApplyInteractIntent( AetheriaRuntimeRunCheckpointCommit run, AetheriaRuntimeDaemonCommandDocument command, - AetheriaRuntimeDaemonIntentState intents) + AetheriaRuntimeDaemonIntentState intents, + double defaultDockingDistance, + double defaultWormholeExitRadius) { var actorKey = ResolveActorEntityKey(run, command); if (string.IsNullOrWhiteSpace(actorKey) || @@ -1185,7 +1204,7 @@ namespace GameCult.Aetheria.State.Verse if (TryFindNearestWormholeTarget( run, actorKey, - command.PositionX, + ResolveInteractionDistance(command.PositionX, defaultWormholeExitRadius), out var targetZoneIndex, out var entryX, out var entryY)) @@ -1196,7 +1215,17 @@ namespace GameCult.Aetheria.State.Verse return ApplyEnterWormholeIntent(run, command, intents); } - return ApplyDockNearestIntent(run, command, intents); + return ApplyDockNearestIntent(run, command, intents, defaultDockingDistance); + } + + private static double ResolveInteractionDistance(double commandDistance, double defaultDistance) + { + if (IsFinite(commandDistance) && commandDistance > 0.0) + return commandDistance; + + return IsFinite(defaultDistance) && defaultDistance > 0.0 + ? defaultDistance + : double.PositiveInfinity; } private static bool TryFindNearestDockTarget( diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommandCatalog.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommandCatalog.cs index b29f23d20..c29ff5060 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommandCatalog.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSurfaceCommandCatalog.cs @@ -81,7 +81,7 @@ namespace GameCult.Aetheria.State.Verse 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.DockNearest => client.DockNearest(observed), AetheriaRuntimeDaemonCommandKinds.Undock => client.Undock(observed), _ => null };