Optimize atmos devices' appearance updating.

This commit is contained in:
Vera Aguilera Puerto
2021-07-30 14:00:14 +02:00
parent f4769c00d7
commit e256cb7bb0
5 changed files with 44 additions and 48 deletions

View File

@@ -27,16 +27,14 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnThermoMachineUpdated(EntityUid uid, GasThermoMachineComponent thermoMachine, AtmosDeviceUpdateEvent args)
{
var appearance = thermoMachine.Owner.GetComponentOrNull<AppearanceComponent>();
appearance?.SetData(ThermoMachineVisuals.Enabled, false);
if (!thermoMachine.Enabled)
return;
if (!ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
return;
if (!nodeContainer.TryGetNode(thermoMachine.InletName, out PipeNode? inlet))
if (!thermoMachine.Enabled
|| !ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
|| !nodeContainer.TryGetNode(thermoMachine.InletName, out PipeNode? inlet))
{
appearance?.SetData(ThermoMachineVisuals.Enabled, false);
return;
}
var airHeatCapacity = _atmosphereSystem.GetHeatCapacity(inlet.Air);
var combinedHeatCapacity = airHeatCapacity + thermoMachine.HeatCapacity;