2021-07-19 12:07:37 +02:00
|
|
|
using Content.Server.Atmos.EntitySystems;
|
2021-06-19 13:25:05 +02:00
|
|
|
using Content.Server.Atmos.Piping.Components;
|
|
|
|
|
using Content.Server.Atmos.Piping.Unary.Components;
|
|
|
|
|
using Content.Server.NodeContainer;
|
2021-07-04 18:11:52 +02:00
|
|
|
using Content.Server.NodeContainer.Nodes;
|
2021-06-19 13:25:05 +02:00
|
|
|
using Content.Shared.Atmos;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-07-26 12:58:17 +02:00
|
|
|
using Robust.Shared.IoC;
|
2021-06-19 13:25:05 +02:00
|
|
|
|
|
|
|
|
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
public class GasOutletInjectorSystem : EntitySystem
|
|
|
|
|
{
|
2021-07-26 12:58:17 +02:00
|
|
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
|
|
|
|
|
2021-06-19 13:25:05 +02:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<GasOutletInjectorComponent, AtmosDeviceUpdateEvent>(OnOutletInjectorUpdated);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnOutletInjectorUpdated(EntityUid uid, GasOutletInjectorComponent injector, AtmosDeviceUpdateEvent args)
|
|
|
|
|
{
|
|
|
|
|
injector.Injecting = false;
|
|
|
|
|
|
|
|
|
|
if (!injector.Enabled)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-09-28 13:35:29 +02:00
|
|
|
if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
|
2021-06-19 13:25:05 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!nodeContainer.TryGetNode(injector.InletName, out PipeNode? inlet))
|
|
|
|
|
return;
|
|
|
|
|
|
2021-12-08 13:00:43 +01:00
|
|
|
var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(injector.Owner).Coordinates, true);
|
2021-06-19 13:25:05 +02:00
|
|
|
|
2021-07-19 12:07:37 +02:00
|
|
|
if (environment == null)
|
2021-06-19 13:25:05 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (inlet.Air.Temperature > 0)
|
|
|
|
|
{
|
|
|
|
|
var transferMoles = inlet.Air.Pressure * injector.VolumeRate / (inlet.Air.Temperature * Atmospherics.R);
|
|
|
|
|
|
|
|
|
|
var removed = inlet.Air.Remove(transferMoles);
|
|
|
|
|
|
2021-07-26 12:58:17 +02:00
|
|
|
_atmosphereSystem.Merge(environment, removed);
|
2021-06-19 13:25:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|