From 521ed99766440838c579c362fefcc2cabf4b256c Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 26 Jun 2022 15:20:45 +1000 Subject: [PATCH] Evac shuttle (#8931) Co-authored-by: metalgearsloth --- Content.Client/Computer/ComputerVisualizer.cs | 5 +- .../BUI/EmergencyConsoleBoundUserInterface.cs | 13 + .../BUI/RadarConsoleBoundUserInterface.cs | 9 + .../Commands/ShowEmergencyShuttleCommand.cs | 17 + .../Systems/ShuttleSystem.EmergencyConsole.cs | 80 + .../Shuttles/UI/EmergencyConsoleWindow.xaml | 41 + .../UI/EmergencyConsoleWindow.xaml.cs | 93 + Content.Client/Shuttles/UI/RadarControl.cs | 7 +- .../Tests/RoundEndTest.cs | 2 +- .../AI/Components/AiControllerComponent.cs | 69 +- .../AI/Steering/AiSteeringSystem.cs | 38 +- .../AI/Utility/AiLogic/UtilityAI.cs | 2 +- .../AlertLevel/AlertLevelPrototype.cs | 5 + .../CommunicationsConsoleSystem.cs | 47 +- .../Doors/Components/AirlockComponent.cs | 2 +- .../Physics/Controllers/MoverController.cs | 5 +- Content.Server/RoundEnd/RoundEndSystem.cs | 60 +- .../Commands/DelayShuttleRoundEndCommand.cs | 29 + .../Commands/DockEmergencyShuttleCommand.cs | 22 + .../Commands/LaunchEmergencyShuttleCommand.cs | 22 + .../Components/EmergencyDockComponent.cs | 7 + .../EmergencyShuttleConsoleComponent.cs | 16 + .../Components/HyperspaceComponent.cs | 31 + .../Shuttles/Components/ShuttleComponent.cs | 6 + .../Components/ShuttleConsoleComponent.cs | 6 + .../Events/EmergencyShuttleAuthorizedEvent.cs | 8 + .../Shuttles/Systems/DockingSystem.cs | 6 +- .../Shuttles/Systems/ShuttleConsoleSystem.cs | 5 +- .../Systems/ShuttleSystem.EmergencyConsole.cs | 263 ++ .../Systems/ShuttleSystem.EmergencyShuttle.cs | 465 +++ .../Systems/ShuttleSystem.Hyperspace.cs | 210 + .../Shuttles/Systems/ShuttleSystem.cs | 62 +- .../Components/StationDataComponent.cs | 18 +- Content.Shared.Database/LogType.cs | 1 + Content.Shared/CCVar/CCVars.cs | 22 + .../SharedPlayerInputMoverComponent.cs | 19 +- .../SharedPlayerMobMoverComponent.cs | 9 - ...EmergencyConsoleBoundUserInterfaceState.cs | 16 + .../EmergencyShuttleAuthorizeMessage.cs | 9 + .../Events/EmergencyShuttlePositionMessage.cs | 13 + .../EmergencyShuttleRepealAllMessage.cs | 9 + .../Events/EmergencyShuttleRepealMessage.cs | 9 + .../EmergencyShuttleRequestPositionMessage.cs | 12 + .../SharedShuttleSystem.EmergencyConsole.cs | 14 + .../Shuttles/Systems/SharedShuttleSystem.cs | 6 + Resources/Audio/Announcements/license.txt | 4 +- .../{shuttledock.ogg => shuttle_dock.ogg} | Bin .../Effects/Shuttle/hyperspace_begin.ogg | Bin 0 -> 82935 bytes .../Audio/Effects/Shuttle/hyperspace_end.ogg | Bin 0 -> 56223 bytes Resources/Audio/Effects/Shuttle/licenses.txt | 5 + .../en-US/round-end/round-end-system.ftl | 6 +- Resources/Locale/en-US/shuttles/emergency.ftl | 33 + Resources/Maps/Shuttles/emergency_shuttle.yml | 3508 +++++++++++++++++ Resources/Prototypes/Access/command.yml | 6 + .../Prototypes/AlertLevels/alert_levels.yml | 5 + .../Prototypes/Entities/Mobs/NPCs/animals.yml | 8 + .../Prototypes/Entities/Mobs/NPCs/bear.yml | 2 + .../Prototypes/Entities/Mobs/NPCs/carp.yml | 2 + .../Entities/Mobs/NPCs/dummy_npcs.yml | 2 + .../Prototypes/Entities/Mobs/NPCs/human.yml | 4 + .../Prototypes/Entities/Mobs/NPCs/mimic.yml | 2 + .../Prototypes/Entities/Mobs/NPCs/pets.yml | 2 + .../Entities/Mobs/NPCs/regalrat.yml | 4 + .../Entities/Mobs/NPCs/simplemob.yml | 4 + .../Entities/Mobs/NPCs/spacetick.yml | 2 + .../Prototypes/Entities/Mobs/NPCs/xeno.yml | 4 + .../Entities/Mobs/Player/familiars.yml | 2 + .../Prototypes/Entities/Mobs/Player/human.yml | 26 +- .../Structures/Doors/Airlocks/access.yml | 13 +- .../Structures/Machines/Computers/arcades.yml | 2 +- .../Computers/base_structurecomputers.yml | 2 +- .../Machines/Computers/computers.yml | 65 +- Resources/clientCommandPerms.yml | 1 + 73 files changed, 5336 insertions(+), 188 deletions(-) create mode 100644 Content.Client/Shuttles/BUI/EmergencyConsoleBoundUserInterface.cs create mode 100644 Content.Client/Shuttles/Commands/ShowEmergencyShuttleCommand.cs create mode 100644 Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs create mode 100644 Content.Client/Shuttles/UI/EmergencyConsoleWindow.xaml create mode 100644 Content.Client/Shuttles/UI/EmergencyConsoleWindow.xaml.cs create mode 100644 Content.Server/Shuttles/Commands/DelayShuttleRoundEndCommand.cs create mode 100644 Content.Server/Shuttles/Commands/DockEmergencyShuttleCommand.cs create mode 100644 Content.Server/Shuttles/Commands/LaunchEmergencyShuttleCommand.cs create mode 100644 Content.Server/Shuttles/Components/EmergencyDockComponent.cs create mode 100644 Content.Server/Shuttles/Components/EmergencyShuttleConsoleComponent.cs create mode 100644 Content.Server/Shuttles/Components/HyperspaceComponent.cs create mode 100644 Content.Server/Shuttles/Events/EmergencyShuttleAuthorizedEvent.cs create mode 100644 Content.Server/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs create mode 100644 Content.Server/Shuttles/Systems/ShuttleSystem.EmergencyShuttle.cs create mode 100644 Content.Server/Shuttles/Systems/ShuttleSystem.Hyperspace.cs create mode 100644 Content.Shared/Shuttles/BUIStates/EmergencyConsoleBoundUserInterfaceState.cs create mode 100644 Content.Shared/Shuttles/Events/EmergencyShuttleAuthorizeMessage.cs create mode 100644 Content.Shared/Shuttles/Events/EmergencyShuttlePositionMessage.cs create mode 100644 Content.Shared/Shuttles/Events/EmergencyShuttleRepealAllMessage.cs create mode 100644 Content.Shared/Shuttles/Events/EmergencyShuttleRepealMessage.cs create mode 100644 Content.Shared/Shuttles/Events/EmergencyShuttleRequestPositionMessage.cs create mode 100644 Content.Shared/Shuttles/Systems/SharedShuttleSystem.EmergencyConsole.cs create mode 100644 Content.Shared/Shuttles/Systems/SharedShuttleSystem.cs rename Resources/Audio/Announcements/{shuttledock.ogg => shuttle_dock.ogg} (100%) create mode 100644 Resources/Audio/Effects/Shuttle/hyperspace_begin.ogg create mode 100644 Resources/Audio/Effects/Shuttle/hyperspace_end.ogg create mode 100644 Resources/Audio/Effects/Shuttle/licenses.txt create mode 100644 Resources/Locale/en-US/shuttles/emergency.ftl create mode 100644 Resources/Maps/Shuttles/emergency_shuttle.yml diff --git a/Content.Client/Computer/ComputerVisualizer.cs b/Content.Client/Computer/ComputerVisualizer.cs index d2c65dfd70..357ba2a766 100644 --- a/Content.Client/Computer/ComputerVisualizer.cs +++ b/Content.Client/Computer/ComputerVisualizer.cs @@ -24,7 +24,8 @@ namespace Content.Client.Computer { base.InitializeEntity(entity); - var sprite = IoCManager.Resolve().GetComponent(entity); + if (!IoCManager.Resolve().TryGetComponent(entity, out var sprite)) return; + sprite.LayerSetState(Layers.Screen, ScreenState); if (!string.IsNullOrEmpty(KeyboardState)) @@ -38,7 +39,7 @@ namespace Content.Client.Computer { base.OnChangeData(component); - var sprite = IoCManager.Resolve().GetComponent(component.Owner); + if (!IoCManager.Resolve().TryGetComponent(component.Owner, out var sprite)) return; if (!component.TryGetData(ComputerVisuals.Powered, out bool powered)) { diff --git a/Content.Client/Shuttles/BUI/EmergencyConsoleBoundUserInterface.cs b/Content.Client/Shuttles/BUI/EmergencyConsoleBoundUserInterface.cs new file mode 100644 index 0000000000..2783f286b7 --- /dev/null +++ b/Content.Client/Shuttles/BUI/EmergencyConsoleBoundUserInterface.cs @@ -0,0 +1,13 @@ +using Content.Client.Computer; +using Content.Client.Shuttles.UI; +using Content.Shared.Shuttles.BUIStates; +using JetBrains.Annotations; +using Robust.Client.GameObjects; + +namespace Content.Client.Shuttles.BUI; + +[UsedImplicitly] +public sealed class EmergencyConsoleBoundUserInterface : ComputerBoundUserInterface +{ + public EmergencyConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) {} +} diff --git a/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs b/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs index 0c2e8bc726..57971bd072 100644 --- a/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs +++ b/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs @@ -19,6 +19,15 @@ public sealed class RadarConsoleBoundUserInterface : BoundUserInterface _window?.OpenCentered(); } + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (disposing) + { + _window?.Dispose(); + } + } + protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); diff --git a/Content.Client/Shuttles/Commands/ShowEmergencyShuttleCommand.cs b/Content.Client/Shuttles/Commands/ShowEmergencyShuttleCommand.cs new file mode 100644 index 0000000000..51430ca315 --- /dev/null +++ b/Content.Client/Shuttles/Commands/ShowEmergencyShuttleCommand.cs @@ -0,0 +1,17 @@ +using Content.Client.Shuttles.Systems; +using Robust.Shared.Console; + +namespace Content.Client.Shuttles.Commands; + +public sealed class ShowEmergencyShuttleCommand : IConsoleCommand +{ + public string Command => "showemergencyshuttle"; + public string Description => "Shows the expected position of the emergency shuttle"; + public string Help => $"{Command}"; + public void Execute(IConsoleShell shell, string argStr, string[] args) + { + var tstalker = IoCManager.Resolve().GetEntitySystem(); + tstalker.EnableShuttlePosition ^= true; + shell.WriteLine($"Set emergency shuttle debug to {tstalker.EnableShuttlePosition}"); + } +} diff --git a/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs b/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs new file mode 100644 index 0000000000..db3f8f5b58 --- /dev/null +++ b/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs @@ -0,0 +1,80 @@ +using Content.Shared.Shuttles.Events; +using Content.Shared.Shuttles.Systems; +using Robust.Client.Graphics; +using Robust.Shared.Enums; + +namespace Content.Client.Shuttles.Systems; + +public sealed partial class ShuttleSystem : SharedShuttleSystem +{ + /// + /// Should we show the expected emergency shuttle position. + /// + public bool EnableShuttlePosition + { + get => _enableShuttlePosition; + set + { + if (_enableShuttlePosition == value) return; + + _enableShuttlePosition = value; + var overlayManager = IoCManager.Resolve(); + + if (_enableShuttlePosition) + { + _overlay = new EmergencyShuttleOverlay(EntityManager); + overlayManager.AddOverlay(_overlay); + RaiseNetworkEvent(new EmergencyShuttleRequestPositionMessage()); + } + else + { + overlayManager.RemoveOverlay(_overlay!); + _overlay = null; + } + } + } + + private bool _enableShuttlePosition; + private EmergencyShuttleOverlay? _overlay; + + public override void Initialize() + { + base.Initialize(); + SubscribeNetworkEvent(OnShuttlePosMessage); + } + + private void OnShuttlePosMessage(EmergencyShuttlePositionMessage ev) + { + if (_overlay == null) return; + + _overlay.StationUid = ev.StationUid; + _overlay.Position = ev.Position; + } +} + +/// +/// Shows the expected position of the emergency shuttle. Nothing more. +/// +public sealed class EmergencyShuttleOverlay : Overlay +{ + private IEntityManager _entManager; + + public override OverlaySpace Space => OverlaySpace.WorldSpace; + + public EntityUid? StationUid; + public Box2? Position; + + public EmergencyShuttleOverlay(IEntityManager entManager) + { + _entManager = entManager; + } + + protected override void Draw(in OverlayDrawArgs args) + { + if (Position == null || !_entManager.TryGetComponent(StationUid, out var xform)) return; + + args.WorldHandle.SetTransform(xform.WorldMatrix); + args.WorldHandle.DrawRect(Position.Value, Color.Red.WithAlpha(100)); + args.WorldHandle.SetTransform(Matrix3.Identity); + } +} diff --git a/Content.Client/Shuttles/UI/EmergencyConsoleWindow.xaml b/Content.Client/Shuttles/UI/EmergencyConsoleWindow.xaml new file mode 100644 index 0000000000..211a5151e8 --- /dev/null +++ b/Content.Client/Shuttles/UI/EmergencyConsoleWindow.xaml @@ -0,0 +1,41 @@ + + +