Cleans up the appearance and ambience of various atmos devices. (#9071)

This commit is contained in:
Vera Aguilera Puerto
2022-06-23 14:18:11 +02:00
committed by GitHub
parent 6b619e6376
commit 9090460e0e
4 changed files with 109 additions and 87 deletions

View File

@@ -36,25 +36,12 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
SubscribeLocalEvent<GasMixerComponent, GasMixerChangeNodePercentageMessage>(OnChangeNodePercentageMessage);
SubscribeLocalEvent<GasMixerComponent, GasMixerToggleStatusMessage>(OnToggleStatusMessage);
// Shouldn't need re-anchor event
SubscribeLocalEvent<GasMixerComponent, AnchorStateChangedEvent>(OnAnchorChanged);
SubscribeLocalEvent<GasMixerComponent, AtmosDeviceDisabledEvent>(OnMixerLeaveAtmosphere);
}
private void OnAnchorChanged(EntityUid uid, GasMixerComponent component, ref AnchorStateChangedEvent args)
private void OnInit(EntityUid uid, GasMixerComponent mixer, ComponentInit args)
{
if (args.Anchored)
return;
component.Enabled = false;
DirtyUI(uid, component);
UpdateAppearance(uid, component);
_userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key);
}
private void OnInit(EntityUid uid, GasMixerComponent component, ComponentInit args)
{
UpdateAppearance(uid, component);
UpdateAppearance(uid, mixer);
}
private void OnMixerUpdated(EntityUid uid, GasMixerComponent mixer, AtmosDeviceUpdateEvent args)
@@ -83,8 +70,6 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
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;
@@ -127,30 +112,44 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
}
// Actually transfer the gas now.
var transferred = false;
if (transferMolesOne > 0f)
{
transferred = true;
var removed = inletOne.Air.Remove(transferMolesOne);
_atmosphereSystem.Merge(outlet.Air, removed);
}
if (transferMolesTwo > 0f)
{
transferred = true;
var removed = inletTwo.Air.Remove(transferMolesTwo);
_atmosphereSystem.Merge(outlet.Air, removed);
}
_ambientSoundSystem.SetAmbience(mixer.Owner, true);
if (transferred)
_ambientSoundSystem.SetAmbience(mixer.Owner, true);
}
private void OnMixerInteractHand(EntityUid uid, GasMixerComponent component, InteractHandEvent args)
private void OnMixerLeaveAtmosphere(EntityUid uid, GasMixerComponent mixer, AtmosDeviceDisabledEvent args)
{
mixer.Enabled = false;
DirtyUI(uid, mixer);
UpdateAppearance(uid, mixer);
_userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key);
}
private void OnMixerInteractHand(EntityUid uid, GasMixerComponent mixer, InteractHandEvent args)
{
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
if (EntityManager.GetComponent<TransformComponent>(component.Owner).Anchored)
if (EntityManager.GetComponent<TransformComponent>(mixer.Owner).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasMixerUiKey.Key, actor.PlayerSession);
DirtyUI(uid, component);
DirtyUI(uid, mixer);
}
else
{