]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Block gas analyzer updates if the UI doesn't open (#28376)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Wed, 29 May 2024 18:19:06 +0000 (04:19 +1000)
committerGitHub <noreply@github.com>
Wed, 29 May 2024 18:19:06 +0000 (10:19 -0800)
Fixes the gas analyzer UI coming up when used with a target.

Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs

index b42f36262936667c37ed52bd063743380f2631ed..c2cdd4a10727ff74a2826138b9fa2b488ed1177e 100644 (file)
@@ -68,7 +68,6 @@ namespace Content.Server.Atmos.EntitySystems
                 return;
             }
             ActivateAnalyzer(uid, component, args.User, args.Target);
-            OpenUserInterface(uid, args.User, component);
             args.Handled = true;
         }
 
@@ -86,6 +85,9 @@ namespace Content.Server.Atmos.EntitySystems
         /// </summary>
         private void ActivateAnalyzer(EntityUid uid, GasAnalyzerComponent component, EntityUid user, EntityUid? target = null)
         {
+            if (!TryOpenUserInterface(uid, user, component))
+                return;
+
             component.Target = target;
             component.User = user;
             if (target != null)
@@ -97,7 +99,6 @@ namespace Content.Server.Atmos.EntitySystems
             UpdateAppearance(uid, component);
             EnsureComp<ActiveGasAnalyzerComponent>(uid);
             UpdateAnalyzer(uid, component);
-            OpenUserInterface(uid, user, component);
         }
 
         /// <summary>
@@ -134,12 +135,12 @@ namespace Content.Server.Atmos.EntitySystems
             DisableAnalyzer(uid, component);
         }
 
-        private void OpenUserInterface(EntityUid uid, EntityUid user, GasAnalyzerComponent? component = null)
+        private bool TryOpenUserInterface(EntityUid uid, EntityUid user, GasAnalyzerComponent? component = null)
         {
             if (!Resolve(uid, ref component, false))
-                return;
+                return false;
 
-            _userInterface.OpenUi(uid, GasAnalyzerUiKey.Key, user);
+            return _userInterface.TryOpenUi(uid, GasAnalyzerUiKey.Key, user);
         }
 
         /// <summary>