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;

View File

@@ -9,6 +9,7 @@ using Content.Server.UserInterface;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping;
using Content.Shared.Atmos.Piping.Trinary.Components;
using Content.Shared.Audio;
using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Popups;
@@ -28,6 +29,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
[Dependency] private UserInterfaceSystem _userInterfaceSystem = default!;
[Dependency] private AdminLogSystem _adminLogSystem = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
public override void Initialize()
{
@@ -50,7 +52,10 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
component.Enabled = false;
if (TryComp(uid, out AppearanceComponent? appearance))
{
appearance.SetData(FilterVisuals.Enabled, false);
_ambientSoundSystem.SetAmbience(component.Owner, false);
}
DirtyUI(uid, component);
_userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key);
@@ -69,6 +74,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
|| outletNode.Air.Pressure >= Atmospherics.MaxOutputPressure) // No need to transfer if target is full.
{
appearance?.SetData(FilterVisuals.Enabled, false);
_ambientSoundSystem.SetAmbience(filter.Owner, false);
return;
}
@@ -78,6 +84,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (transferRatio <= 0)
{
appearance?.SetData(FilterVisuals.Enabled, false);
_ambientSoundSystem.SetAmbience(filter.Owner, false);
return;
}
@@ -94,6 +101,14 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
var target = filterNode.Air.Pressure < Atmospherics.MaxOutputPressure ? filterNode : inletNode;
_atmosphereSystem.Merge(target.Air, filteredOut);
if (filteredOut.Pressure != 0f)
{
_ambientSoundSystem.SetAmbience(filter.Owner, true);
}
else
{
_ambientSoundSystem.SetAmbience(filter.Owner, false);
}
}
_atmosphereSystem.Merge(outletNode.Air, removed);

View File

@@ -7,6 +7,7 @@ using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping;
using Content.Shared.Atmos.Piping.Trinary.Components;
using Content.Shared.Audio;
using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Popups;
@@ -21,6 +22,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
[Dependency] private UserInterfaceSystem _userInterfaceSystem = default!;
[Dependency] private AdminLogSystem _adminLogSystem = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
public override void Initialize()
{
@@ -59,7 +61,10 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
// TODO ATMOS: Cache total moles since it's expensive.
if (!mixer.Enabled)
{
_ambientSoundSystem.SetAmbience(mixer.Owner, false);
return;
}
if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
return;
@@ -67,13 +72,18 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (!nodeContainer.TryGetNode(mixer.InletOneName, out PipeNode? inletOne)
|| !nodeContainer.TryGetNode(mixer.InletTwoName, out PipeNode? inletTwo)
|| !nodeContainer.TryGetNode(mixer.OutletName, out PipeNode? outlet))
{
_ambientSoundSystem.SetAmbience(mixer.Owner, false);
return;
}
var outputStartingPressure = outlet.Air.Pressure;
if (outputStartingPressure >= mixer.TargetPressure)
return; // Target reached, no need to mix.
var generalTransfer = (mixer.TargetPressure - outputStartingPressure) * outlet.Air.Volume / Atmospherics.R;
var transferMolesOne = inletOne.Air.Temperature > 0 ? mixer.InletOneConcentration * generalTransfer / inletOne.Air.Temperature : 0f;
@@ -102,7 +112,10 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
return;
if (transferMolesOne <= 0 || transferMolesTwo <= 0)
{
_ambientSoundSystem.SetAmbience(mixer.Owner, false);
return;
}
if (inletOne.Air.TotalMoles < transferMolesOne || inletTwo.Air.TotalMoles < transferMolesTwo)
{
@@ -125,6 +138,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
var removed = inletTwo.Air.Remove(transferMolesTwo);
_atmosphereSystem.Merge(outlet.Air, removed);
}
_ambientSoundSystem.SetAmbience(mixer.Owner, true);
}
private void OnMixerInteractHand(EntityUid uid, GasMixerComponent component, InteractHandEvent args)

View File

@@ -13,6 +13,7 @@ using Content.Shared.Atmos;
using Content.Shared.Atmos.Monitor;
using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Atmos.Visuals;
using Content.Shared.Audio;
using JetBrains.Annotations;
using Robust.Shared.Timing;
@@ -24,6 +25,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
public override void Initialize()
{
@@ -52,6 +54,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|| !nodeContainer.TryGetNode(vent.InletName, out PipeNode? pipe))
{
appearance?.SetData(VentPumpVisuals.State, VentPumpState.Off);
_ambientSoundSystem.SetAmbience(vent.Owner, false);
return;
}
@@ -61,6 +64,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (environment == null)
{
appearance?.SetData(VentPumpVisuals.State, VentPumpState.Off);
_ambientSoundSystem.SetAmbience(vent.Owner, false);
return;
}
@@ -70,6 +74,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (vent.PumpDirection == VentPumpDirection.Releasing && pipe.Air.Pressure > 0)
{
appearance?.SetData(VentPumpVisuals.State, VentPumpState.Out);
_ambientSoundSystem.SetAmbience(vent.Owner, true);
if (environment.Pressure > vent.MaxPressure)
return;

View File

@@ -14,6 +14,7 @@ using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Unary.Visuals;
using Content.Shared.Atmos.Monitor;
using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Audio;
using JetBrains.Annotations;
using Robust.Shared.Timing;
@@ -25,6 +26,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
public override void Initialize()
{
@@ -44,6 +46,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (scrubber.Welded)
{
appearance?.SetData(ScrubberVisuals.State, ScrubberState.Welded);
_ambientSoundSystem.SetAmbience(scrubber.Owner, false);
return;
}
@@ -57,8 +60,10 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|| !nodeContainer.TryGetNode(scrubber.OutletName, out PipeNode? outlet))
{
appearance?.SetData(ScrubberVisuals.State, ScrubberState.Off);
_ambientSoundSystem.SetAmbience(scrubber.Owner, false);
return;
}
_ambientSoundSystem.SetAmbience(scrubber.Owner, true);
var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(scrubber.Owner).Coordinates, true);