Files
tbd-station-14/Content.Server/Pinpointer/StationMapSystem.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

53 lines
1.7 KiB
C#

using Content.Server.PowerCell;
using Content.Shared.Pinpointer;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
namespace Content.Server.Pinpointer;
public sealed class StationMapSystem : EntitySystem
{
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly PowerCellSystem _cell = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<StationMapUserComponent, EntParentChangedMessage>(OnUserParentChanged);
Subs.BuiEvents<StationMapComponent>(StationMapUiKey.Key, subs =>
{
subs.Event<BoundUIOpenedEvent>(OnStationMapOpened);
subs.Event<BoundUIClosedEvent>(OnStationMapClosed);
});
}
private void OnStationMapClosed(EntityUid uid, StationMapComponent component, BoundUIClosedEvent args)
{
if (!Equals(args.UiKey, StationMapUiKey.Key) || args.Session.AttachedEntity == null)
return;
RemCompDeferred<StationMapUserComponent>(args.Session.AttachedEntity.Value);
}
private void OnUserParentChanged(EntityUid uid, StationMapUserComponent component, ref EntParentChangedMessage args)
{
if (TryComp<ActorComponent>(uid, out var actor))
{
_ui.TryClose(component.Map, StationMapUiKey.Key, actor.PlayerSession);
}
}
private void OnStationMapOpened(EntityUid uid, StationMapComponent component, BoundUIOpenedEvent args)
{
if (args.Session.AttachedEntity == null)
return;
if (!_cell.TryUseActivatableCharge(uid))
return;
var comp = EnsureComp<StationMapUserComponent>(args.Session.AttachedEntity.Value);
comp.Map = uid;
}
}