diff --git a/Robust.Shared/GameObjects/Components/UserInterface/BoundUserInterface.cs b/Robust.Shared/GameObjects/Components/UserInterface/BoundUserInterface.cs index ea96e6f701a..f2cd0f1f06f 100644 --- a/Robust.Shared/GameObjects/Components/UserInterface/BoundUserInterface.cs +++ b/Robust.Shared/GameObjects/Components/UserInterface/BoundUserInterface.cs @@ -15,6 +15,8 @@ public abstract class BoundUserInterface : IDisposable [Dependency] protected readonly ISharedPlayerManager PlayerManager = default!; protected readonly SharedUserInterfaceSystem UiSystem; + public bool IsOpened { get; protected set; } + public readonly Enum UiKey; public EntityUid Owner { get; } @@ -43,6 +45,10 @@ protected BoundUserInterface(EntityUid owner, Enum uiKey) /// protected internal virtual void Open() { + if (IsOpened) + return; + + IsOpened = true; } /// @@ -93,6 +99,10 @@ protected internal virtual void ReceiveMessage(BoundUserInterfaceMessage message /// public void Close() { + if (!IsOpened) + return; + + IsOpened = false; UiSystem.CloseUi(Owner, UiKey, PlayerManager.LocalEntity, predicted: true); } diff --git a/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs b/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs index 70f2e077376..6c950f3fc30 100644 --- a/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs +++ b/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs @@ -487,7 +487,7 @@ private void OnUserInterfaceHandleState(Entity ent, ref ent.Comp.States[key] = buiState; - if (!ent.Comp.ClientOpenInterfaces.TryGetValue(key, out var cBui)) + if (!ent.Comp.ClientOpenInterfaces.TryGetValue(key, out var cBui) || !cBui.IsOpened) continue; cBui.State = buiState;