Fix gas analyser error. (#11386)

This commit is contained in:
Leon Friedrich
2022-09-18 11:10:10 +12:00
committed by GitHub
parent 49e1b7d4dc
commit 42f080d665

View File

@@ -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<ActiveGasAnalyzerComponent>(uid))
AddComp<ActiveGasAnalyzerComponent>(uid);
UpdateAnalyzer(uid);
UpdateAnalyzer(uid, component);
}
/// <summary>
@@ -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);