Ambience enhancements. (#7073)

This commit is contained in:
Moony
2022-03-12 16:20:31 -06:00
committed by GitHub
parent 6d2c5868a3
commit f5c92caef4
29 changed files with 290 additions and 68 deletions

View File

@@ -8,6 +8,7 @@ using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping;
using Content.Shared.Atmos.Piping.Binary.Components;
using Content.Shared.Audio;
using Content.Shared.Database;
using Content.Shared.Examine;
using Content.Shared.Interaction;
@@ -20,9 +21,10 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
[UsedImplicitly]
public sealed class GasPressurePumpSystem : EntitySystem
{
[Dependency] private UserInterfaceSystem _userInterfaceSystem = default!;
[Dependency] private AdminLogSystem _adminLogSystem = default!;
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
[Dependency] private readonly AdminLogSystem _adminLogSystem = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
public override void Initialize()
{
@@ -59,6 +61,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|| !nodeContainer.TryGetNode(pump.OutletName, out PipeNode? outlet))
{
appearance?.SetData(PumpVisuals.Enabled, false);
_ambientSoundSystem.SetAmbience(pump.Owner, false);
return;
}
@@ -67,12 +70,14 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (MathHelper.CloseToPercent(pump.TargetPressure, outputStartingPressure))
{
appearance?.SetData(PumpVisuals.Enabled, false);
_ambientSoundSystem.SetAmbience(pump.Owner, false);
return; // No need to pump gas if target has been reached.
}
if (inlet.Air.TotalMoles > 0 && inlet.Air.Temperature > 0)
{
appearance?.SetData(PumpVisuals.Enabled, true);
_ambientSoundSystem.SetAmbience(pump.Owner, true);
// We calculate the necessary moles to transfer using our good ol' friend PV=nRT.
var pressureDelta = pump.TargetPressure - outputStartingPressure;

View File

@@ -20,6 +20,8 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
[UsedImplicitly]
public sealed class GasValveSystem : EntitySystem
{
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
public override void Initialize()
{
base.Initialize();
@@ -68,11 +70,13 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{
inlet.AddAlwaysReachable(outlet);
outlet.AddAlwaysReachable(inlet);
_ambientSoundSystem.SetAmbience(component.Owner, true);
}
else
{
inlet.RemoveAlwaysReachable(outlet);
outlet.RemoveAlwaysReachable(inlet);
_ambientSoundSystem.SetAmbience(component.Owner, false);
}
}
}

View File

@@ -6,6 +6,7 @@ using Content.Server.NodeContainer;
using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos.Piping;
using Content.Shared.Atmos.Piping.Binary.Components;
using Content.Shared.Audio;
using Content.Shared.Database;
using Content.Shared.Examine;
using Content.Shared.Interaction;
@@ -21,8 +22,9 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private UserInterfaceSystem _userInterfaceSystem = default!;
[Dependency] private AdminLogSystem _adminLogSystem = default!;
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
[Dependency] private readonly AdminLogSystem _adminLogSystem = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
public override void Initialize()
{
@@ -59,6 +61,8 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|| !nodeContainer.TryGetNode(pump.OutletName, out PipeNode? outlet))
{
appearance?.SetData(PumpVisuals.Enabled, false);
_ambientSoundSystem.SetAmbience(pump.Owner, false);
_ambientSoundSystem.SetAmbience(pump.Owner, false);
return;
}
@@ -74,6 +78,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
return;
appearance?.SetData(PumpVisuals.Enabled, true);
_ambientSoundSystem.SetAmbience(pump.Owner, true);
// We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters.
var transferRatio = (float)(pump.TransferRate * (_gameTiming.CurTime - device.LastProcess).TotalSeconds) / inlet.Air.Volume;