From f99741937cb919b3351d6bf47fa09c9db7c4f1b0 Mon Sep 17 00:00:00 2001 From: Ilya246 <57039557+Ilya246@users.noreply.github.com> Date: Sun, 6 Aug 2023 21:23:43 +0400 Subject: [PATCH] Adjust radiator flow rate and fix space detection (#18764) The previous dT did not accurately represent the actual tick time. This is being investigated separately. Check environment mixture for zero moles, because space mixtures do not necessarily return null. While here, make an unrelated style change involving TryComp. --- Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs b/Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs index 6ef617b0cd..7aa8b18949 100644 --- a/Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs +++ b/Content.Server/Atmos/EntitySystems/HeatExchangerSystem.cs @@ -21,6 +21,7 @@ public sealed class HeatExchangerSystem : EntitySystem [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly NodeContainerSystem _nodeContainer = default!; + [Dependency] private IGameTiming _gameTiming = default!; float tileLoss; @@ -46,7 +47,8 @@ public sealed class HeatExchangerSystem : EntitySystem private void OnAtmosUpdate(EntityUid uid, HeatExchangerComponent comp, AtmosDeviceUpdateEvent args) { - if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer) + if (!TryComp(uid, out NodeContainerComponent? nodeContainer) + || !TryComp(uid, out AtmosDeviceComponent? device) || !_nodeContainer.TryGetNode(nodeContainer, comp.InletName, out PipeNode? inlet) || !_nodeContainer.TryGetNode(nodeContainer, comp.OutletName, out PipeNode? outlet)) { @@ -54,7 +56,7 @@ public sealed class HeatExchangerSystem : EntitySystem } // Positive dN flows from inlet to outlet - var dt = 1/_atmosphereSystem.AtmosTickRate; + var dt = (float)(_gameTiming.CurTime - device.LastProcess).TotalSeconds; var dP = inlet.Air.Pressure - outlet.Air.Pressure; var dN = comp.G*dP*dt; @@ -68,7 +70,7 @@ public sealed class HeatExchangerSystem : EntitySystem // Convection var environment = _atmosphereSystem.GetContainingMixture(uid, true, true); - if (environment != null) + if (environment != null && environment.TotalMoles != 0) { radTemp = environment.Temperature;