Files
tbd-station-14/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.Drone.cs
Pieter-Jan Briers 123a4147de BUI bugfixes / improvements (#23881)
* Fix ActivatableUIRequiresPowerCellComponent stopping power draw when one of two people closes the UI.

Also fixes it to check UiKey properly.

* Remove unnecessary CrewManifestViewer on PDAs

This is for a pop-up crew manifest UI, which the PDA doesn't use.

* Fix BoundUIClosedEvents that didn't check UI key/not correctly at least.

Uses the new helper method in engine.

* Fix drone (cargo shuttle) pilot console UI breaking if two people open it and one person closes it.

* Fixes for disposal router/tagger UI.

Code was badly copy pasted without changing identifiers, never worked.

Also cleaned up some of the logic (text trimming, sounds).

Also removed the "refuse to work if you have something in your active hand" check like why.

* Avoid running most ActivatableUIComponent logic when closing a UI via toggle

Activating the UI while it's already open closes it via toggle. Except it still ran 99% of the "attempting to open" logic which makes no sense.

This probably fixes a bug or some other dumb behavior somewhere.

* Bitch
2024-01-14 18:18:39 +11:00

77 lines
2.3 KiB
C#

using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Station.Components;
using Content.Server.UserInterface;
namespace Content.Server.Shuttles.Systems;
public sealed partial class ShuttleConsoleSystem
{
/// <summary>
/// Refreshes all drone console entities.
/// </summary>
public void RefreshDroneConsoles()
{
var query = AllEntityQuery<DroneConsoleComponent>();
while (query.MoveNext(out var uid, out var comp))
{
comp.Entity = GetShuttleConsole(uid, comp);
}
}
private void OnDronePilotConsoleOpen(EntityUid uid, DroneConsoleComponent component, AfterActivatableUIOpenEvent args)
{
component.Entity = GetShuttleConsole(uid);
}
private void OnDronePilotConsoleClose(EntityUid uid, DroneConsoleComponent component, BoundUIClosedEvent args)
{
// Only if last person closed UI.
if (!_ui.IsUiOpen(uid, args.UiKey))
component.Entity = null;
}
private void OnCargoGetConsole(EntityUid uid, DroneConsoleComponent component, ref ConsoleShuttleEvent args)
{
args.Console = GetShuttleConsole(uid, component);
}
/// <summary>
/// Gets the relevant shuttle console to proxy from the drone console.
/// </summary>
private EntityUid? GetShuttleConsole(EntityUid uid, DroneConsoleComponent? component = null)
{
if (!Resolve(uid, ref component))
return null;
var stationUid = _station.GetOwningStation(uid);
if (stationUid == null)
return null;
// I know this sucks but needs device linking or something idunno
var query = AllEntityQuery<ShuttleConsoleComponent, TransformComponent>();
while (query.MoveNext(out var cUid, out _, out var xform))
{
if (xform.GridUid == null ||
!TryComp<StationMemberComponent>(xform.GridUid, out var member) ||
member.Station != stationUid)
{
continue;
}
foreach (var compType in component.Components.Values)
{
if (!HasComp(xform.GridUid, compType.Component.GetType()))
continue;
return cUid;
}
}
return null;
}
}