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 @@ + + +