Evac shuttle (#8931)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -24,7 +24,8 @@ namespace Content.Client.Computer
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent>(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<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent>(component.Owner, out var sprite)) return;
|
||||
|
||||
if (!component.TryGetData(ComputerVisuals.Powered, out bool powered))
|
||||
{
|
||||
|
||||
@@ -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<EmergencyConsoleWindow, EmergencyConsoleBoundUserInterfaceState>
|
||||
{
|
||||
public EmergencyConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) {}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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<IEntitySystemManager>().GetEntitySystem<ShuttleSystem>();
|
||||
tstalker.EnableShuttlePosition ^= true;
|
||||
shell.WriteLine($"Set emergency shuttle debug to {tstalker.EnableShuttlePosition}");
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Should we show the expected emergency shuttle position.
|
||||
/// </summary>
|
||||
public bool EnableShuttlePosition
|
||||
{
|
||||
get => _enableShuttlePosition;
|
||||
set
|
||||
{
|
||||
if (_enableShuttlePosition == value) return;
|
||||
|
||||
_enableShuttlePosition = value;
|
||||
var overlayManager = IoCManager.Resolve<IOverlayManager>();
|
||||
|
||||
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<EmergencyShuttlePositionMessage>(OnShuttlePosMessage);
|
||||
}
|
||||
|
||||
private void OnShuttlePosMessage(EmergencyShuttlePositionMessage ev)
|
||||
{
|
||||
if (_overlay == null) return;
|
||||
|
||||
_overlay.StationUid = ev.StationUid;
|
||||
_overlay.Position = ev.Position;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the expected position of the emergency shuttle. Nothing more.
|
||||
/// </summary>
|
||||
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<TransformComponent>(StationUid, out var xform)) return;
|
||||
|
||||
args.WorldHandle.SetTransform(xform.WorldMatrix);
|
||||
args.WorldHandle.DrawRect(Position.Value, Color.Red.WithAlpha(100));
|
||||
args.WorldHandle.SetTransform(Matrix3.Identity);
|
||||
}
|
||||
}
|
||||
41
Content.Client/Shuttles/UI/EmergencyConsoleWindow.xaml
Normal file
41
Content.Client/Shuttles/UI/EmergencyConsoleWindow.xaml
Normal file
@@ -0,0 +1,41 @@
|
||||
<userInterface:FancyWindow xmlns="https://spacestation14.io"
|
||||
xmlns:userInterface="clr-namespace:Content.Client.UserInterface"
|
||||
Title="Emergency Shuttle Console"
|
||||
MinSize="400 400">
|
||||
<BoxContainer Orientation="Vertical"
|
||||
Margin="5">
|
||||
<Label Name="Countdown"
|
||||
HorizontalAlignment="Center"
|
||||
Text="00:00"/>
|
||||
<BoxContainer Name="EngineStatusContainer"
|
||||
HorizontalAlignment="Center">
|
||||
<Label HorizontalAlignment="Center"
|
||||
Text="{Loc 'emergency-shuttle-ui-engines'}"/>
|
||||
<Label Name="EngineStatus"
|
||||
HorizontalAlignment="Center"
|
||||
FontColorOverride="#FFA500"
|
||||
Text="{Loc 'emergency-shuttle-ui-idle'}"/>
|
||||
</BoxContainer>
|
||||
<BoxContainer Name="LaunchContainer">
|
||||
<Label Text="{Loc 'emergency-shuttle-ui-early-authorize'}"/>
|
||||
<Button Name="RepealAllButton" Text="{Loc 'emergency-shuttle-ui-repeal-all'}"/>
|
||||
</BoxContainer>
|
||||
<!-- Spacer -->
|
||||
<BoxContainer Name="AuthorizeContainer">
|
||||
<Button Name="AuthorizeButton"
|
||||
Text="{Loc 'emergency-shuttle-ui-authorize'}"/>
|
||||
<Button Name="RepealButton" Text="{Loc 'emergency-shuttle-ui-repeal'}"/>
|
||||
</BoxContainer>
|
||||
<BoxContainer Name="AuthorizationsTextContainer">
|
||||
<Label Text="{Loc 'emergency-shuttle-ui-authorizations'}"/>
|
||||
<Label Name="AuthorizationCount"
|
||||
Text="{Loc 'emergency-shuttle-ui-remaining'}"
|
||||
HorizontalAlignment="Right"
|
||||
Align="Right"
|
||||
HorizontalExpand="True"/>
|
||||
</BoxContainer>
|
||||
<!-- Spacer -->
|
||||
<BoxContainer Name="AuthorizationsContainer" Orientation="Vertical">
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</userInterface:FancyWindow>
|
||||
93
Content.Client/Shuttles/UI/EmergencyConsoleWindow.xaml.cs
Normal file
93
Content.Client/Shuttles/UI/EmergencyConsoleWindow.xaml.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using Content.Client.Computer;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.Shuttles.BUIStates;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Shuttles.UI;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class EmergencyConsoleWindow : FancyWindow,
|
||||
IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
|
||||
{
|
||||
private readonly IGameTiming _timing;
|
||||
private TimeSpan? _earlyLaunchTime;
|
||||
|
||||
public EmergencyConsoleWindow()
|
||||
{
|
||||
_timing = IoCManager.Resolve<IGameTiming>();
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void SetupComputerWindow(ComputerBoundUserInterfaceBase cb)
|
||||
{
|
||||
RepealAllButton.OnPressed += args =>
|
||||
{
|
||||
OnRepealAllPressed(cb, args);
|
||||
};
|
||||
AuthorizeButton.OnPressed += args =>
|
||||
{
|
||||
OnAuthorizePressed(cb, args);
|
||||
};
|
||||
RepealButton.OnPressed += args =>
|
||||
{
|
||||
OnRepealPressed(cb, args);
|
||||
};
|
||||
}
|
||||
|
||||
private void OnRepealAllPressed(ComputerBoundUserInterfaceBase cb, BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
cb.SendMessage(new EmergencyShuttleRepealAllMessage());
|
||||
}
|
||||
|
||||
private void OnRepealPressed(ComputerBoundUserInterfaceBase cb, BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
cb.SendMessage(new EmergencyShuttleRepealMessage());
|
||||
}
|
||||
|
||||
private void OnAuthorizePressed(ComputerBoundUserInterfaceBase cb, BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
cb.SendMessage(new EmergencyShuttleAuthorizeMessage());
|
||||
}
|
||||
|
||||
public void UpdateState(EmergencyConsoleBoundUserInterfaceState scc)
|
||||
{
|
||||
// TODO: Loc and cvar for this.
|
||||
_earlyLaunchTime = scc.EarlyLaunchTime;
|
||||
|
||||
AuthorizationsContainer.DisposeAllChildren();
|
||||
var remainingAuths = scc.AuthorizationsRequired - scc.Authorizations.Count;
|
||||
AuthorizationCount.Text = Loc.GetString("emergency-shuttle-ui-remaining", ("remaining", remainingAuths));
|
||||
|
||||
foreach (var auth in scc.Authorizations)
|
||||
{
|
||||
AuthorizationsContainer.AddChild(new Label
|
||||
{
|
||||
Text = auth,
|
||||
FontColorOverride = Color.Lime,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Draw(DrawingHandleScreen handle)
|
||||
{
|
||||
base.Draw(handle);
|
||||
if (_earlyLaunchTime == null)
|
||||
{
|
||||
Countdown.Text = "00:10";
|
||||
}
|
||||
else
|
||||
{
|
||||
var remaining = _earlyLaunchTime.Value - _timing.CurTime;
|
||||
|
||||
if (remaining < TimeSpan.Zero)
|
||||
remaining = TimeSpan.Zero;
|
||||
|
||||
Countdown.Text = $"{remaining.Minutes:00}:{remaining.Seconds:00}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public sealed class RadarControl : Control
|
||||
/// </summary>
|
||||
private Dictionary<EntityUid, Control> _iffControls = new();
|
||||
|
||||
private Dictionary<EntityUid, Dictionary<EntityUid, DockingInterfaceState>> _docks = new();
|
||||
private Dictionary<EntityUid, List<DockingInterfaceState>> _docks = new();
|
||||
|
||||
public bool ShowIFF { get; set; } = true;
|
||||
public bool ShowDocks { get; set; } = true;
|
||||
@@ -88,7 +88,7 @@ public sealed class RadarControl : Control
|
||||
{
|
||||
var coordinates = state.Coordinates;
|
||||
var grid = _docks.GetOrNew(coordinates.EntityId);
|
||||
grid.Add(state.Entity, state);
|
||||
grid.Add(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,8 +288,9 @@ public sealed class RadarControl : Control
|
||||
|
||||
if (_docks.TryGetValue(uid, out var docks))
|
||||
{
|
||||
foreach (var (ent, state) in docks)
|
||||
foreach (var state in docks)
|
||||
{
|
||||
var ent = state.Entity;
|
||||
var position = state.Coordinates.Position;
|
||||
var uiPosition = matrix.Transform(position);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user