From 42f080d66522392377ba3623f2e6c1a7cc36a39b Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 18 Sep 2022 11:10:10 +1200 Subject: [PATCH] Fix gas analyser error. (#11386) --- .../Atmos/EntitySystems/GasAnalyzerSystem.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs b/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs index 1fffb78cef..39e63e4e25 100644 --- a/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs @@ -1,4 +1,4 @@ -using Content.Server.Atmos; +using Content.Server.Atmos; using Content.Server.Atmos.Components; using Content.Server.NodeContainer; using Content.Server.NodeContainer.Nodes; @@ -87,7 +87,7 @@ namespace Content.Server.Atmos.EntitySystems UpdateAppearance(component); if(!HasComp(uid)) AddComp(uid); - UpdateAnalyzer(uid); + UpdateAnalyzer(uid, component); } /// @@ -143,8 +143,14 @@ namespace Content.Server.Atmos.EntitySystems if (!Resolve(uid, ref component)) return false; + if (!TryComp(component.User, out TransformComponent? xform)) + { + DisableAnalyzer(uid, component); + return false; + } + // check if the user has walked away from what they scanned - var userPos = Transform(component.User).Coordinates; + var userPos = xform.Coordinates; if (component.LastPosition.HasValue) { // Check if position is out of range => don't update and disable @@ -175,6 +181,13 @@ namespace Content.Server.Atmos.EntitySystems var deviceFlipped = false; if (component.Target != null) { + if (Deleted(component.Target)) + { + component.Target = null; + DisableAnalyzer(uid, component, component.User); + return false; + } + // gas analyzed was used on an entity, try to request gas data via event for override var ev = new GasAnalyzerScanEvent(); RaiseLocalEvent(component.Target.Value, ev, false);