Block gas analyzer updates if the UI doesn't open (#28376)

Fixes the gas analyzer UI coming up when used with a target.
This commit is contained in:
metalgearsloth
2024-05-30 04:19:06 +10:00
committed by GitHub
parent 5d79f897b9
commit 962a1192bd

View 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>