Gas Analyzer can now scan pipes/devices along with the environment (#10976)

This commit is contained in:
theashtronaut
2022-09-08 14:22:14 +00:00
committed by GitHub
parent ae8fe43529
commit 868abaca5c
23 changed files with 826 additions and 758 deletions

View File

@@ -38,6 +38,7 @@ namespace Content.Server.Atmos.Portable
SubscribeLocalEvent<PortableScrubberComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<PortableScrubberComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<PortableScrubberComponent, DestructionEventArgs>(OnDestroyed);
SubscribeLocalEvent<PortableScrubberComponent, GasAnalyzerScanEvent>(OnScrubberAnalyzed);
}
private void OnDeviceUpdated(EntityUid uid, PortableScrubberComponent component, AtmosDeviceUpdateEvent args)
@@ -158,5 +159,21 @@ namespace Content.Server.Atmos.Portable
appearance.SetData(PortableScrubberVisuals.IsDraining, isDraining);
}
/// <summary>
/// Returns the gas mixture for the gas analyzer
/// </summary>
private void OnScrubberAnalyzed(EntityUid uid, PortableScrubberComponent component, GasAnalyzerScanEvent args)
{
var gasMixDict = new Dictionary<string, GasMixture?>();
// If it's connected to a port, include the port side
if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
{
if(nodeContainer != null && nodeContainer.TryGetNode(component.PortName, out PipeNode? port))
gasMixDict.Add(component.PortName, port.Air);
}
gasMixDict.Add(Name(uid), component.Air);
args.GasMixtures = gasMixDict;
}
}
}