fix gas tank UI (#7135)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Content.Shared.Atmos.Components;
|
||||
using Content.Shared.Atmos.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -38,7 +38,8 @@ namespace Content.Client.UserInterface.Atmos.GasTank
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
_window?.UpdateState((GasTankBoundUserInterfaceState) state);
|
||||
if (state is GasTankBoundUserInterfaceState cast)
|
||||
_window?.UpdateState(cast);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
||||
@@ -91,12 +91,6 @@ namespace Content.Server.Atmos.Components
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenInterface(IPlayerSession session)
|
||||
{
|
||||
_userInterface?.Open(session);
|
||||
UpdateUserInterface(true);
|
||||
}
|
||||
|
||||
public void Examine(FormattedMessage message, bool inDetailsRange)
|
||||
{
|
||||
message.AddMarkup(Loc.GetString("comp-gas-tank-examine", ("pressure", Math.Round(Air?.Pressure ?? 0))));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Toggleable;
|
||||
@@ -19,12 +20,18 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<GasTankComponent, GetVerbsEvent<ActivationVerb>>(AddOpenUIVerb);
|
||||
SubscribeLocalEvent<GasTankComponent, BeforeActivatableUIOpenEvent>(BeforeUiOpen);
|
||||
SubscribeLocalEvent<GasTankComponent, GetActionsEvent>(OnGetActions);
|
||||
SubscribeLocalEvent<GasTankComponent, ToggleActionEvent>(OnActionToggle);
|
||||
SubscribeLocalEvent<GasTankComponent, DroppedEvent>(OnDropped);
|
||||
}
|
||||
|
||||
private void BeforeUiOpen(EntityUid uid, GasTankComponent component, BeforeActivatableUIOpenEvent args)
|
||||
{
|
||||
// Only initial update includes output pressure information, to avoid overwriting client-input as the updates come in.
|
||||
component.UpdateUserInterface(true);
|
||||
}
|
||||
|
||||
private void OnDropped(EntityUid uid, GasTankComponent component, DroppedEvent args)
|
||||
{
|
||||
component.DisconnectFromInternals(args.User);
|
||||
@@ -45,18 +52,6 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void AddOpenUIVerb(EntityUid uid, GasTankComponent component, GetVerbsEvent<ActivationVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !EntityManager.TryGetComponent<ActorComponent?>(args.User, out var actor))
|
||||
return;
|
||||
|
||||
ActivationVerb verb = new();
|
||||
verb.Act = () => component.OpenInterface(actor.PlayerSession);
|
||||
verb.Text = Loc.GetString("control-verb-open-control-panel-text");
|
||||
// TODO VERBS add "open UI" icon?
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
Reference in New Issue
Block a user