2023-06-28 14:28:38 +03:00
|
|
|
using Content.Server.NodeContainer.EntitySystems;
|
2021-07-12 09:47:59 +02:00
|
|
|
using Content.Server.NodeContainer.Nodes;
|
2025-05-15 04:06:37 +10:00
|
|
|
using Content.Shared.Atmos.Piping.Binary.Components;
|
|
|
|
|
using Content.Shared.Atmos.Piping.Binary.Systems;
|
2021-11-06 17:32:33 -07:00
|
|
|
using Content.Shared.Audio;
|
2021-07-12 09:47:59 +02:00
|
|
|
|
2025-05-15 04:06:37 +10:00
|
|
|
namespace Content.Server.Atmos.Piping.Binary.EntitySystems;
|
2022-03-12 16:20:31 -06:00
|
|
|
|
2025-05-15 04:06:37 +10:00
|
|
|
public sealed class GasValveSystem : SharedGasValveSystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
|
|
|
|
|
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
|
2021-07-12 09:47:59 +02:00
|
|
|
|
2025-05-15 04:06:37 +10:00
|
|
|
public override void Set(EntityUid uid, GasValveComponent component, bool value)
|
|
|
|
|
{
|
|
|
|
|
base.Set(uid, component, value);
|
2021-10-19 21:46:31 +00:00
|
|
|
|
2025-05-15 04:06:37 +10:00
|
|
|
if (_nodeContainer.TryGetNodes(uid, component.InletName, component.OutletName, out PipeNode? inlet, out PipeNode? outlet))
|
2021-10-19 21:46:31 +00:00
|
|
|
{
|
2025-05-15 04:06:37 +10:00
|
|
|
if (component.Open)
|
2023-11-27 22:12:34 +11:00
|
|
|
{
|
2025-05-15 04:06:37 +10:00
|
|
|
inlet.AddAlwaysReachable(outlet);
|
|
|
|
|
outlet.AddAlwaysReachable(inlet);
|
|
|
|
|
_ambientSoundSystem.SetAmbience(uid, true);
|
2023-11-27 22:12:34 +11:00
|
|
|
}
|
2025-05-15 04:06:37 +10:00
|
|
|
else
|
2021-07-12 09:47:59 +02:00
|
|
|
{
|
2025-05-15 04:06:37 +10:00
|
|
|
inlet.RemoveAlwaysReachable(outlet);
|
|
|
|
|
outlet.RemoveAlwaysReachable(inlet);
|
|
|
|
|
_ambientSoundSystem.SetAmbience(uid, false);
|
2021-07-12 09:47:59 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|