* Predicted gas pumps I wanted to try out atmos and first thing I found. * a * Atmos device prediction - Canisters - Tanks - Internals AirMixes aren't predicted so nothing on that front but all the UIs should be a lot closer. * Remove details range * Gas tank prediction * Even more sweeping changes * Alerts * rehg * Popup fix * Fix merge conflicts * Fix * Review
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using Content.Shared.Popups;
|
|
|
|
namespace Content.Shared.UserInterface;
|
|
|
|
/// <summary>
|
|
/// <see cref="ActivatableUIRequiresAnchorComponent"/>
|
|
/// </summary>
|
|
public sealed class ActivatableUIRequiresAnchorSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<ActivatableUIRequiresAnchorComponent, ActivatableUIOpenAttemptEvent>(OnActivatableUIOpenAttempt);
|
|
SubscribeLocalEvent<ActivatableUIRequiresAnchorComponent, BoundUserInterfaceCheckRangeEvent>(OnUICheck);
|
|
}
|
|
|
|
private void OnUICheck(Entity<ActivatableUIRequiresAnchorComponent> ent, ref BoundUserInterfaceCheckRangeEvent args)
|
|
{
|
|
if (args.Result == BoundUserInterfaceRangeResult.Fail)
|
|
return;
|
|
|
|
if (!Transform(ent.Owner).Anchored)
|
|
{
|
|
args.Result = BoundUserInterfaceRangeResult.Fail;
|
|
}
|
|
}
|
|
|
|
private void OnActivatableUIOpenAttempt(Entity<ActivatableUIRequiresAnchorComponent> ent, ref ActivatableUIOpenAttemptEvent args)
|
|
{
|
|
if (args.Cancelled)
|
|
return;
|
|
|
|
if (!Transform(ent.Owner).Anchored)
|
|
{
|
|
if (ent.Comp.Popup != null)
|
|
{
|
|
_popup.PopupClient(Loc.GetString(ent.Comp.Popup), args.User);
|
|
}
|
|
|
|
args.Cancel();
|
|
}
|
|
}
|
|
}
|