From 5598b1d87fcb36228c4beb5e51e4c269ba133ff8 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 11 Jul 2026 03:16:45 +0100 Subject: [PATCH] feat(input): advertise live pilot actions --- Aetheria.State.Daemon/Program.cs | 3 + Aetheria.State/AetheriaDocumentRegistry.cs | 1 + ...AetheriaRuntimeInputCapabilityDocuments.cs | 95 +++++++++++++++++++ .../Runtime/AetheriaRuntimeVerseClient.cs | 3 + 4 files changed, 102 insertions(+) create mode 100644 Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputCapabilityDocuments.cs diff --git a/Aetheria.State.Daemon/Program.cs b/Aetheria.State.Daemon/Program.cs index aa7a8da16..4552224e6 100644 --- a/Aetheria.State.Daemon/Program.cs +++ b/Aetheria.State.Daemon/Program.cs @@ -1335,6 +1335,9 @@ static async Task PublishDaemonApiDocumentsAsync( await node.MutableDocument(AetheriaRuntimeVerseRecordKeys.StarbridgeSessionSummary) .ReplaceAsync(result.StarbridgeSessionSummary) .ConfigureAwait(false); + await node.MutableDocument(AetheriaRuntimeVerseRecordKeys.PilotInputCapability) + .ReplaceAsync(AetheriaRuntimeInputCapabilityDocument.FromFrame(result.Frame)) + .ConfigureAwait(false); var mainMenuState = await node.MutableDocument(AetheriaStateNode.MainMenuStateKey) .ReadAsync() .ConfigureAwait(false); diff --git a/Aetheria.State/AetheriaDocumentRegistry.cs b/Aetheria.State/AetheriaDocumentRegistry.cs index 3f3598fc2..ecf320eaa 100644 --- a/Aetheria.State/AetheriaDocumentRegistry.cs +++ b/Aetheria.State/AetheriaDocumentRegistry.cs @@ -60,6 +60,7 @@ public static class AetheriaDocumentRegistry typeof(AetheriaRuntimeStarbridgeScenarioDocument), typeof(AetheriaRuntimeStarbridgeSessionDocument), typeof(AetheriaRuntimeStarbridgeSessionSummaryDocument), + typeof(AetheriaRuntimeInputCapabilityDocument), typeof(AetheriaRuntimeDaemonSoaViewDocument), typeof(AetheriaRuntimeVerseAuthorityPolicyDocument), typeof(AetheriaRuntimeAuthorityLeaseDocument), diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputCapabilityDocuments.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputCapabilityDocuments.cs new file mode 100644 index 000000000..f987ead7f --- /dev/null +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputCapabilityDocuments.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using GameCult.Caching; +using MessagePack; + +namespace GameCult.Aetheria.State.Verse +{ + [MessagePackObject] + public sealed class AetheriaRuntimeInputGestureDocument + { + [Key(0)] public string Kind { get; set; } = "direct"; + [Key(1)] public string[] Controls { get; set; } = Array.Empty(); + [Key(2)] public int MaxStepIntervalMs { get; set; } = 650; + [Key(3)] public string CompletionControl { get; set; } = ""; + } + + [MessagePackObject] + public sealed class AetheriaRuntimeInputBindingDocument + { + [Key(0)] public string BindingId { get; set; } = ""; + [Key(1)] public string ActionId { get; set; } = ""; + [Key(2)] public AetheriaRuntimeInputGestureDocument Gesture { get; set; } = new AetheriaRuntimeInputGestureDocument(); + [Key(3)] public bool ActionBar { get; set; } + } + + [MessagePackObject] + public sealed class AetheriaRuntimeInputActionDocument + { + [Key(0)] public string ActionId { get; set; } = ""; + [Key(1)] public string Label { get; set; } = ""; + [Key(2)] public string Operation { get; set; } = ""; + [Key(3)] public string Context { get; set; } = "pilot"; + [Key(4)] public string Category { get; set; } = "ship"; + [Key(5)] public string Availability { get; set; } = "available"; + [Key(6)] public string SourceRef { get; set; } = ""; + } + + [MessagePackObject] + public sealed class AetheriaRuntimeInputProfileDocument + { + [Key(0)] public string ProfileId { get; set; } = ""; + [Key(1)] public string DeviceClass { get; set; } = ""; + [Key(2)] public AetheriaRuntimeInputBindingDocument[] Bindings { get; set; } = Array.Empty(); + } + + [CultDocument("gamecult.eve.input_capability", "gamecult.eve.input_capability.v1")] + [MessagePackObject] + public sealed class AetheriaRuntimeInputCapabilityDocument + { + public const string SchemaId = "gamecult.eve.input_capability.v1"; + [Key(0)] public string Schema { get; set; } = SchemaId; + [Key(1)] public string ProviderId { get; set; } = "aetheria.daemon"; + [Key(2)] public string CapabilityId { get; set; } = "aetheria.pilot.input"; + [Key(3)] public long Version { get; set; } + [Key(4)] public AetheriaRuntimeInputActionDocument[] Actions { get; set; } = Array.Empty(); + [Key(5)] public AetheriaRuntimeInputProfileDocument[] DefaultProfiles { get; set; } = Array.Empty(); + + public static AetheriaRuntimeInputCapabilityDocument FromFrame(AetheriaRuntimeDaemonFrameDocument frame) + { + var run = frame?.Run ?? new AetheriaRuntimeRunCheckpointCommit(); + var entity = run.Zones.SelectMany(zone => zone.Entities).FirstOrDefault(candidate => + string.Equals(run.EntityRecordKey(run.CurrentZoneIndex, candidate.EntityIndex), run.CurrentEntityKey, StringComparison.Ordinal)); + var actions = CoreActions().ToList(); + if (entity != null) + { + actions.AddRange((entity.WeaponGroups ?? Array.Empty>()).Select((_, index) => Action($"weapon-group.{index}.fire", $"Fire Weapon Group {index + 1}", "FireWeaponGroup", "weapon-group", $"{run.CurrentEntityKey}#weapon-group/{index}"))); + actions.AddRange((entity.Equipment ?? Array.Empty()).Where(slot => slot?.Item != null).Select((slot, index) => Action($"equipment.{index}.activate", $"Activate {slot.Item.ItemKey}", "SetBehaviorActive", "equipment", $"{run.CurrentEntityKey}#equipment/{index}"))); + actions.AddRange((entity.CargoContents ?? Array.Empty()).SelectMany(bay => bay.Items).Where(slot => slot?.Item != null).Select((slot, index) => Action($"cargo.{slot.Item.ItemKey}.{index}.use", $"Use {slot.Item.ItemKey}", "ActivateConsumable", "consumable", $"{run.CurrentEntityKey}#cargo/{index}"))); + } + return new AetheriaRuntimeInputCapabilityDocument { Version = frame?.FrameId ?? 0, Actions = actions.ToArray(), DefaultProfiles = BuildDefaultProfiles() }; + } + + private static IEnumerable CoreActions() + { + yield return Action("pilot.fire", "Fire", "FireWeaponGroup", "combat", "pilot"); + yield return Action("pilot.scoop", "Scoop", "SetTractorPower", "ship", "pilot"); + yield return Action("pilot.dock", "Dock", "DockNearest", "ship", "pilot"); + yield return Action("pilot.undock", "Undock", "Undock", "ship", "pilot"); + yield return Action("pilot.target-nearest", "Target Nearest", "TargetNearest", "targeting", "pilot"); + } + + private static AetheriaRuntimeInputActionDocument Action(string id, string label, string operation, string category, string source) => + new AetheriaRuntimeInputActionDocument { ActionId = id, Label = label, Operation = "aetheria.daemon.commands." + operation, Category = category, SourceRef = source }; + + private static AetheriaRuntimeInputProfileDocument[] BuildDefaultProfiles() => new[] + { + Profile("keyboard-mouse", "keyboard-mouse", Binding("fire.mouse", "pilot.fire", "direct", "mouse.primary"), Binding("scoop.shift", "pilot.scoop", "direct", "keyboard.leftShift"), Binding("dock.r", "pilot.dock", "direct", "keyboard.r")), + Profile("gamepad", "gamepad", Binding("fire.trigger", "pilot.fire", "direct", "gamepad.rightTrigger"), Binding("scoop.sequence", "pilot.scoop", "sequence", "gamepad.dpad.down", "gamepad.dpad.right"), Binding("dock.sequence", "pilot.dock", "sequence", "gamepad.dpad.down", "gamepad.dpad.up")) + }; + + private static AetheriaRuntimeInputProfileDocument Profile(string id, string device, params AetheriaRuntimeInputBindingDocument[] bindings) => new AetheriaRuntimeInputProfileDocument { ProfileId = id, DeviceClass = device, Bindings = bindings }; + private static AetheriaRuntimeInputBindingDocument Binding(string id, string action, string kind, params string[] controls) => new AetheriaRuntimeInputBindingDocument { BindingId = id, ActionId = action, Gesture = new AetheriaRuntimeInputGestureDocument { Kind = kind, Controls = controls }, ActionBar = true }; + } +} diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs index 0db1460d8..c3d83091b 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs @@ -70,6 +70,9 @@ namespace GameCult.Aetheria.State.Verse public static CultRecordKey StarbridgeCommanderSurface { get; } = new CultRecordKey("eve:surface:aetheria.starbridge.commander"); + public static CultRecordKey PilotInputCapability { get; } = + new CultRecordKey("eve:input:aetheria.pilot"); + public static CultRecordKey DaemonGameTuiSurface { get; } = new CultRecordKey("eve:surface:aetheria.daemon.game.tui");