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.
This commit is contained in:
Ilya246
2023-08-06 21:23:43 +04:00
committed by GitHub
parent 88d2aef378
commit f99741937c

View File

@@ -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;