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

@@ -31,6 +31,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
SubscribeLocalEvent<GasMixerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<GasMixerComponent, AtmosDeviceUpdateEvent>(OnMixerUpdated);
SubscribeLocalEvent<GasMixerComponent, InteractHandEvent>(OnMixerInteractHand);
SubscribeLocalEvent<GasMixerComponent, GasAnalyzerScanEvent>(OnMixerAnalyzed);
// Bound UI subscriptions
SubscribeLocalEvent<GasMixerComponent, GasMixerChangeOutputPressureMessage>(OnOutputPressureChangeMessage);
SubscribeLocalEvent<GasMixerComponent, GasMixerChangeNodePercentageMessage>(OnChangeNodePercentageMessage);
@@ -203,5 +204,29 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
$"{EntityManager.ToPrettyString(args.Session.AttachedEntity!.Value):player} set the ratio on {EntityManager.ToPrettyString(uid):device} to {mixer.InletOneConcentration}:{mixer.InletTwoConcentration}");
DirtyUI(uid, mixer);
}
/// <summary>
/// Returns the gas mixture for the gas analyzer
/// </summary>
private void OnMixerAnalyzed(EntityUid uid, GasMixerComponent component, GasAnalyzerScanEvent args)
{
if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
return;
var gasMixDict = new Dictionary<string, GasMixture?>();
nodeContainer.TryGetNode(component.InletOneName, out PipeNode? inletOne);
nodeContainer.TryGetNode(component.InletTwoName, out PipeNode? inletTwo);
if(inletOne != null)
gasMixDict.Add($"{inletOne.CurrentPipeDirection} {Loc.GetString("gas-analyzer-window-text-inlet")}", inletOne.Air);
if(inletTwo != null)
gasMixDict.Add($"{inletTwo.CurrentPipeDirection} {Loc.GetString("gas-analyzer-window-text-inlet")}", inletTwo.Air);
if(nodeContainer.TryGetNode(component.OutletName, out PipeNode? outlet))
gasMixDict.Add(Loc.GetString("gas-analyzer-window-text-outlet"), outlet.Air);
args.GasMixtures = gasMixDict;
args.DeviceFlipped = inletOne != null && inletTwo != null && inletOne.CurrentPipeDirection.ToDirection() == inletTwo.CurrentPipeDirection.ToDirection().GetClockwise90Degrees();
}
}
}