From 1251b3aedae5f3f88e055ce91f0849ceb486faf1 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Fri, 15 Jul 2022 14:11:41 +1000 Subject: [PATCH] Add FTL destinations (#9685) --- .../Nutrition/Components/HungerComponent.cs | 2 - .../BUI/ShuttleConsoleBoundUserInterface.cs | 9 + Content.Client/Shuttles/UI/RadarControl.cs | 42 +- .../Shuttles/UI/ShuttleConsoleWindow.xaml | 21 +- .../Shuttles/UI/ShuttleConsoleWindow.xaml.cs | 96 +- .../StationCargoOrderDatabaseComponent.cs | 4 +- .../Cargo/Systems/CargoSystem.Shuttle.cs | 48 +- Content.Server/Cargo/Systems/CargoSystem.cs | 5 - .../GameTicking/Rules/NukeopsRuleSystem.cs | 53 +- .../Physics/Controllers/MoverController.cs | 12 +- .../Shuttles/Components/DockingComponent.cs | 3 + .../Shuttles/Components/FTLComponent.cs | 52 + .../Components/FTLDestinationComponent.cs | 19 + .../Components/HyperspaceComponent.cs | 37 - .../Shuttles/Components/ShuttleComponent.cs | 6 - .../Components/ShuttleConsoleComponent.cs | 6 - .../Shuttles/Systems/DockingSystem.cs | 39 +- .../Shuttles/Systems/ShuttleConsoleSystem.cs | 114 +- .../Systems/ShuttleSystem.EmergencyConsole.cs | 52 +- .../Systems/ShuttleSystem.EmergencyShuttle.cs | 8 +- ...ce.cs => ShuttleSystem.FasterThanLight.cs} | 204 +- .../Shuttles/Systems/ShuttleSystem.cs | 25 +- .../Shuttles/Systems/SpaceGarbageSystem.cs | 5 +- .../ShuttleConsoleBoundInterfaceState.cs | 17 + .../ShuttleConsoleDestinationMessage.cs | 12 + .../Shuttles/Systems/SharedShuttleSystem.cs | 28 + .../Effects/Shuttle/hyperspace_progress.ogg | Bin 0 -> 37313 bytes Resources/Audio/Effects/Shuttle/licenses.txt | 4 +- .../en-US/cargo/cargo-console-component.ftl | 2 +- Resources/Locale/en-US/shuttles/console.ftl | 17 +- Resources/Maps/centcomm.yml | 2 + Resources/Maps/nukieplanet.yml | 8410 +++++++++++++++++ .../Machines/Computers/computers.yml | 3 + Resources/Prototypes/tags.yml | 3 + 34 files changed, 9133 insertions(+), 227 deletions(-) create mode 100644 Content.Server/Shuttles/Components/FTLComponent.cs create mode 100644 Content.Server/Shuttles/Components/FTLDestinationComponent.cs delete mode 100644 Content.Server/Shuttles/Components/HyperspaceComponent.cs rename Content.Server/Shuttles/Systems/{ShuttleSystem.Hyperspace.cs => ShuttleSystem.FasterThanLight.cs} (55%) create mode 100644 Content.Shared/Shuttles/Events/ShuttleConsoleDestinationMessage.cs create mode 100644 Resources/Audio/Effects/Shuttle/hyperspace_progress.ogg create mode 100644 Resources/Maps/nukieplanet.yml diff --git a/Content.Client/Nutrition/Components/HungerComponent.cs b/Content.Client/Nutrition/Components/HungerComponent.cs index 4dea387b44..db1b3383e3 100644 --- a/Content.Client/Nutrition/Components/HungerComponent.cs +++ b/Content.Client/Nutrition/Components/HungerComponent.cs @@ -22,8 +22,6 @@ namespace Content.Client.Nutrition.Components } _currentHungerThreshold = hunger.CurrentThreshold; - - EntitySystem.Get().RefreshMovementSpeedModifiers(Owner); } } } diff --git a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs index b1cde98993..63f71f8dc2 100644 --- a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs +++ b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs @@ -22,10 +22,19 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface _window.UndockPressed += OnUndockPressed; _window.StartAutodockPressed += OnAutodockPressed; _window.StopAutodockPressed += OnStopAutodockPressed; + _window.DestinationPressed += OnDestinationPressed; _window.OpenCentered(); _window.OnClose += OnClose; } + private void OnDestinationPressed(EntityUid obj) + { + SendMessage(new ShuttleConsoleDestinationMessage() + { + Destination = obj, + }); + } + private void OnClose() { Close(); diff --git a/Content.Client/Shuttles/UI/RadarControl.cs b/Content.Client/Shuttles/UI/RadarControl.cs index d93c051d23..580510ec56 100644 --- a/Content.Client/Shuttles/UI/RadarControl.cs +++ b/Content.Client/Shuttles/UI/RadarControl.cs @@ -35,6 +35,11 @@ public sealed class RadarControl : Control private float _radarMaxRange = 256f; public float RadarRange { get; private set; } = 256f; + /// + /// Controls the maximum distance that IFF labels will display. + /// + public float MaxRadarRange { get; private set; } = 256f * 10f; + private int MidPoint => SizeFull / 2; private int SizeFull => (int) ((MinimapRadius + MinimapMargin) * 2 * UIScale); private int ScaledMinimapRadius => (int) (MinimapRadius * UIScale); @@ -182,7 +187,7 @@ public sealed class RadarControl : Control // Draw other grids... differently foreach (var grid in _mapManager.FindGridsIntersecting(mapPosition.MapId, - new Box2(mapPosition.Position - RadarRange, mapPosition.Position + RadarRange))) + new Box2(mapPosition.Position - MaxRadarRange, mapPosition.Position + MaxRadarRange))) { if (grid.GridEntityId == ourGridId) continue; @@ -206,19 +211,25 @@ public sealed class RadarControl : Control if (ShowIFF) { + Label label; + if (!_iffControls.TryGetValue(grid.GridEntityId, out var control)) { - var label = new Label() + label = new Label() { HorizontalAlignment = HAlignment.Left, + FontColorOverride = Color.Aquamarine, }; control = new PanelContainer() { - HorizontalAlignment = HAlignment.Left, - VerticalAlignment = VAlignment.Top, - Children = { label }, - StyleClasses = { StyleNano.StyleClassTooltipPanel }, + HorizontalAlignment = HAlignment.Center, + VerticalAlignment = VAlignment.Center, + Children = + { + label + }, + StyleClasses = { StyleNano.StyleClassBorderedWindowPanel }, }; _iffControls[grid.GridEntityId] = control; @@ -227,20 +238,17 @@ public sealed class RadarControl : Control var gridCentre = matty.Transform(gridBody.LocalCenter); gridCentre.Y = -gridCentre.Y; + var distance = gridCentre.Length; - // TODO: When we get IFF or whatever we can show controls at a further distance; for now - // we don't do that because it would immediately reveal nukies. - if (gridCentre.Length < RadarRange) + if (gridCentre.Length > RadarRange) { - control.Visible = true; - var label = (Label) control.GetChild(0); - label.Text = Loc.GetString("shuttle-console-iff-label", ("name", name), ("distance", $"{gridCentre.Length:0.0}")); - LayoutContainer.SetPosition(control, ScalePosition(gridCentre) / UIScale); - } - else - { - control.Visible = false; + gridCentre = gridCentre.Normalized * RadarRange; } + + control.Visible = true; + label = (Label) control.GetChild(0); + label.Text = Loc.GetString("shuttle-console-iff-label", ("name", name), ("distance", $"{distance:0.0}")); + LayoutContainer.SetPosition(control, ScalePosition(gridCentre) / UIScale); } else { diff --git a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml index 868bed16dc..548c136d0a 100644 --- a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml +++ b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml @@ -4,7 +4,8 @@ xmlns:ui1="clr-namespace:Content.Client.HUD.UI" Title="{Loc 'shuttle-console-window-title'}"> + HorizontalAlignment="Stretch" + Margin="5 5 5 5"> + + + + + + @@ -40,6 +49,14 @@ +