using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.Piping.Components; using Content.Server.Atmos.Piping.Unary.Components; using Content.Server.NodeContainer; using Content.Server.NodeContainer.Nodes; using Content.Shared.Atmos; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.Atmos.Piping.Unary.EntitySystems { [UsedImplicitly] public class GasOutletInjectorSystem : EntitySystem { [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnOutletInjectorUpdated); } private void OnOutletInjectorUpdated(EntityUid uid, GasOutletInjectorComponent injector, AtmosDeviceUpdateEvent args) { injector.Injecting = false; if (!injector.Enabled) return; if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)) return; if (!nodeContainer.TryGetNode(injector.InletName, out PipeNode? inlet)) return; var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve().GetComponent(injector.Owner).Coordinates, true); if (environment == null) return; if (inlet.Air.Temperature > 0) { var transferMoles = inlet.Air.Pressure * injector.VolumeRate / (inlet.Air.Temperature * Atmospherics.R); var removed = inlet.Air.Remove(transferMoles); _atmosphereSystem.Merge(environment, removed); } } } }