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

@@ -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)