using System; using System.Collections.Generic; using System.Linq; #nullable enable namespace GameCult.Aetheria.State.Verse { public static class AetheriaRuntimeDaemonSurfaceCommandCatalog { public const string CommandPrefix = "aetheria.daemon.commands."; private static readonly AetheriaRuntimeDaemonCommandKinds[] ArgumentlessCommandKinds = { AetheriaRuntimeDaemonCommandKinds.ClearTarget, AetheriaRuntimeDaemonCommandKinds.TargetNearest, AetheriaRuntimeDaemonCommandKinds.TargetNext, AetheriaRuntimeDaemonCommandKinds.TargetPrevious, AetheriaRuntimeDaemonCommandKinds.SetMoveVector, AetheriaRuntimeDaemonCommandKinds.SetLookDirection, AetheriaRuntimeDaemonCommandKinds.SetTractorPower, AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup, AetheriaRuntimeDaemonCommandKinds.SetWeaponGroupActive, AetheriaRuntimeDaemonCommandKinds.SensorPing, AetheriaRuntimeDaemonCommandKinds.SetHeatsinksEnabled, AetheriaRuntimeDaemonCommandKinds.SetOverrideShutdown, AetheriaRuntimeDaemonCommandKinds.ToggleShieldEnabled, AetheriaRuntimeDaemonCommandKinds.DockNearest, AetheriaRuntimeDaemonCommandKinds.Undock }; public static IReadOnlyList ArgumentlessCommands => ArgumentlessCommandKinds; public static IReadOnlyList ArgumentlessSurfaceCommands => ArgumentlessCommandKinds .Select(kind => new AetheriaRuntimeSurfaceCommandTemplate( CommandName(kind), Label(kind), AetheriaRuntimeSurfaceCommandTemplate.CultMeshTransport)) .ToArray(); public static string CommandName(AetheriaRuntimeDaemonCommandKinds kind) { return CommandPrefix + kind; } public static string Label(AetheriaRuntimeDaemonCommandKinds kind) { return kind.ToString(); } public static bool IsArgumentlessCommand(AetheriaRuntimeDaemonCommandKinds kind) { return ArgumentlessCommandKinds.Contains(kind); } internal static bool TrySubmitArgumentless( AetheriaRuntimeDaemonOperationClient client, AetheriaRuntimeDaemonFrameDocument? frame, AetheriaRuntimeDaemonCommandKinds kind, out AetheriaRuntimeDaemonCommandEnvelope? envelope) { envelope = null; if (client == null || !IsArgumentlessCommand(kind)) return false; try { envelope = kind switch { AetheriaRuntimeDaemonCommandKinds.ClearTarget => client.ClearTarget(frame), AetheriaRuntimeDaemonCommandKinds.TargetNearest => client.TargetNearest(frame), AetheriaRuntimeDaemonCommandKinds.TargetNext => client.TargetNext(frame), AetheriaRuntimeDaemonCommandKinds.TargetPrevious => client.TargetPrevious(frame), AetheriaRuntimeDaemonCommandKinds.SetMoveVector => client.SetMoveVector(frame, 0.0, 1.0), AetheriaRuntimeDaemonCommandKinds.SetLookDirection => client.SetLookDirection(frame, 0.0, 1.0, 0.0), AetheriaRuntimeDaemonCommandKinds.SetTractorPower => client.SetTractorPower(frame, 1.0), AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup => client.FireWeaponGroup(frame, 0), AetheriaRuntimeDaemonCommandKinds.SetWeaponGroupActive => client.SetWeaponGroupActive(frame, 0, true), AetheriaRuntimeDaemonCommandKinds.SensorPing => client.SensorPing(frame), AetheriaRuntimeDaemonCommandKinds.SetHeatsinksEnabled => client.SetHeatsinksEnabled(frame, true), AetheriaRuntimeDaemonCommandKinds.SetOverrideShutdown => client.SetOverrideShutdown(frame, true), AetheriaRuntimeDaemonCommandKinds.ToggleShieldEnabled => client.ToggleShieldEnabled(frame), AetheriaRuntimeDaemonCommandKinds.DockNearest => client.DockNearest(frame), AetheriaRuntimeDaemonCommandKinds.Undock => client.Undock(frame), _ => null }; return envelope != null; } catch (InvalidOperationException) { envelope = null; return false; } } } }