Files
Delta-v/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPassiveVentSystem.cs
T
733d479425 Move a metric fuckton of AtmosphereSystem to Shared. (#42989)
* AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

* fix the tests I broke

* Remove methods that the client shouldn't be calling. Hamburger.

* light cleanup for now

* review

* whoop

* docs updates and misc changes

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
2026-06-29 12:44:04 +02:00

46 lines
1.6 KiB
C#

using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Piping.Unary.Components;
using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using JetBrains.Annotations;
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
{
[UsedImplicitly]
public sealed class GasPassiveVentSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GasPassiveVentComponent, AtmosDeviceUpdateEvent>(OnPassiveVentUpdated);
}
private void OnPassiveVentUpdated(EntityUid uid, GasPassiveVentComponent vent, ref AtmosDeviceUpdateEvent args)
{
var environment = _atmosphereSystem.GetContainingMixture(uid, args.Grid, args.Map, true, true);
if (environment == null)
return;
if (!_nodeContainer.TryGetNode(uid, vent.InletName, out PipeNode? inlet))
return;
var inletAir = inlet.Air.RemoveRatio(1f);
var envAir = environment.RemoveRatio(1f);
var mergeAir = new GasMixture(inletAir.Volume + envAir.Volume);
_atmosphereSystem.Merge(mergeAir, inletAir);
_atmosphereSystem.Merge(mergeAir, envAir);
_atmosphereSystem.Merge(inlet.Air, mergeAir.RemoveVolume(inletAir.Volume));
_atmosphereSystem.Merge(environment, mergeAir);
}
}
}