GasFilter appearance, EnabledAtmosDeviceVisualizer improvements.
This commit is contained in:
@@ -3,7 +3,9 @@ using Content.Server.Atmos.Piping.Trinary.Components;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Piping;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -24,33 +26,35 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
|
||||
|
||||
private void OnFilterUpdated(EntityUid uid, GasFilterComponent filter, AtmosDeviceUpdateEvent args)
|
||||
{
|
||||
if (!filter.Enabled)
|
||||
return;
|
||||
var appearance = filter.Owner.GetComponentOrNull<AppearanceComponent>();
|
||||
|
||||
if (!ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
|
||||
if (!filter.Enabled
|
||||
|| !ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
|
||||
|| !ComponentManager.TryGetComponent(uid, out AtmosDeviceComponent? device)
|
||||
|| !nodeContainer.TryGetNode(filter.InletName, out PipeNode? inletNode)
|
||||
|| !nodeContainer.TryGetNode(filter.FilterName, out PipeNode? filterNode)
|
||||
|| !nodeContainer.TryGetNode(filter.OutletName, out PipeNode? outletNode)
|
||||
|| outletNode.Air.Pressure >= Atmospherics.MaxOutputPressure) // No need to transfer if target is full.
|
||||
{
|
||||
appearance?.SetData(FilterVisuals.Enabled, false);
|
||||
return;
|
||||
|
||||
if (!ComponentManager.TryGetComponent(uid, out AtmosDeviceComponent? device))
|
||||
return;
|
||||
|
||||
if (!nodeContainer.TryGetNode(filter.InletName, out PipeNode? inletNode)
|
||||
|| !nodeContainer.TryGetNode(filter.FilterName, out PipeNode? filterNode)
|
||||
|| !nodeContainer.TryGetNode(filter.OutletName, out PipeNode? outletNode))
|
||||
return;
|
||||
|
||||
if (outletNode.Air.Pressure >= Atmospherics.MaxOutputPressure)
|
||||
return; // No need to transfer if target is full.
|
||||
}
|
||||
|
||||
// We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters.
|
||||
var transferRatio = (float)(filter.TransferRate * (_gameTiming.CurTime - device.LastProcess).TotalSeconds) / inletNode.Air.Volume;
|
||||
|
||||
if (transferRatio <= 0)
|
||||
{
|
||||
appearance?.SetData(FilterVisuals.Enabled, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var removed = inletNode.Air.RemoveRatio(transferRatio);
|
||||
|
||||
if (filter.FilteredGas.HasValue)
|
||||
{
|
||||
appearance?.SetData(FilterVisuals.Enabled, true);
|
||||
|
||||
var filteredOut = new GasMixture() {Temperature = removed.Temperature};
|
||||
|
||||
filteredOut.SetMoles(filter.FilteredGas.Value, removed.GetMoles(filter.FilteredGas.Value));
|
||||
|
||||
Reference in New Issue
Block a user