diff --git a/Content.Client/UserInterface/Atmos/GasTank/GasTankBoundUserInterface.cs b/Content.Client/UserInterface/Atmos/GasTank/GasTankBoundUserInterface.cs index 2b9a7b0818..71405dfb2f 100644 --- a/Content.Client/UserInterface/Atmos/GasTank/GasTankBoundUserInterface.cs +++ b/Content.Client/UserInterface/Atmos/GasTank/GasTankBoundUserInterface.cs @@ -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) diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index c41d81de55..26543b0cac 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -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)))); diff --git a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs index 2286f65beb..7451891023 100644 --- a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs @@ -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>(AddOpenUIVerb); + SubscribeLocalEvent(BeforeUiOpen); SubscribeLocalEvent(OnGetActions); SubscribeLocalEvent(OnActionToggle); SubscribeLocalEvent(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 args) - { - if (!args.CanAccess || !EntityManager.TryGetComponent(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);