Predicted gas pumps (#33717)

* Predicted gas pumps

I wanted to try out atmos and first thing I found.

* a

* Remove details range
This commit is contained in:
metalgearsloth
2024-12-07 14:39:52 +11:00
committed by GitHub
parent 4beb1016cc
commit 9365e3a99b
26 changed files with 355 additions and 308 deletions

View File

@@ -0,0 +1,41 @@
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)
{
_popup.PopupClient(Loc.GetString("comp-gas-pump-ui-needs-anchor"), args.User);
args.Cancel();
}
}
}