Disable mixer and filter on unanchor (#6577)

This commit is contained in:
Leon Friedrich
2022-02-10 16:28:11 +13:00
committed by GitHub
parent 7549adf2f4
commit b417c022bf
2 changed files with 29 additions and 0 deletions

View File

@@ -39,6 +39,21 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
SubscribeLocalEvent<GasFilterComponent, GasFilterChangeRateMessage>(OnTransferRateChangeMessage); SubscribeLocalEvent<GasFilterComponent, GasFilterChangeRateMessage>(OnTransferRateChangeMessage);
SubscribeLocalEvent<GasFilterComponent, GasFilterSelectGasMessage>(OnSelectGasMessage); SubscribeLocalEvent<GasFilterComponent, GasFilterSelectGasMessage>(OnSelectGasMessage);
SubscribeLocalEvent<GasFilterComponent, GasFilterToggleStatusMessage>(OnToggleStatusMessage); SubscribeLocalEvent<GasFilterComponent, GasFilterToggleStatusMessage>(OnToggleStatusMessage);
SubscribeLocalEvent<GasFilterComponent, AnchorStateChangedEvent>(OnAnchorChanged);
}
private void OnAnchorChanged(EntityUid uid, GasFilterComponent component, ref AnchorStateChangedEvent args)
{
if (args.Anchored)
return;
component.Enabled = false;
if (TryComp(uid, out AppearanceComponent? appearance))
appearance.SetData(FilterVisuals.Enabled, false);
DirtyUI(uid, component);
_userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key);
} }
private void OnFilterUpdated(EntityUid uid, GasFilterComponent filter, AtmosDeviceUpdateEvent args) private void OnFilterUpdated(EntityUid uid, GasFilterComponent filter, AtmosDeviceUpdateEvent args)

View File

@@ -33,6 +33,20 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
SubscribeLocalEvent<GasMixerComponent, GasMixerChangeOutputPressureMessage>(OnOutputPressureChangeMessage); SubscribeLocalEvent<GasMixerComponent, GasMixerChangeOutputPressureMessage>(OnOutputPressureChangeMessage);
SubscribeLocalEvent<GasMixerComponent, GasMixerChangeNodePercentageMessage>(OnChangeNodePercentageMessage); SubscribeLocalEvent<GasMixerComponent, GasMixerChangeNodePercentageMessage>(OnChangeNodePercentageMessage);
SubscribeLocalEvent<GasMixerComponent, GasMixerToggleStatusMessage>(OnToggleStatusMessage); SubscribeLocalEvent<GasMixerComponent, GasMixerToggleStatusMessage>(OnToggleStatusMessage);
SubscribeLocalEvent<GasMixerComponent, AnchorStateChangedEvent>(OnAnchorChanged);
}
private void OnAnchorChanged(EntityUid uid, GasMixerComponent component, ref AnchorStateChangedEvent 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) private void OnInit(EntityUid uid, GasMixerComponent component, ComponentInit args)