diff --git a/Content.Client/GameObjects/Components/Atmos/GasFilterVisualizer.cs b/Content.Client/GameObjects/Components/Atmos/GasFilterVisualizer.cs new file mode 100644 index 0000000000..9f9aa09c64 --- /dev/null +++ b/Content.Client/GameObjects/Components/Atmos/GasFilterVisualizer.cs @@ -0,0 +1,52 @@ +#nullable enable +using Content.Shared.GameObjects.Components.Atmos; +using JetBrains.Annotations; +using Robust.Client.GameObjects; +using Robust.Client.Interfaces.GameObjects.Components; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Serialization; +using Robust.Shared.Utility; +using YamlDotNet.RepresentationModel; + +namespace Content.Client.GameObjects.Components.Atmos +{ + [UsedImplicitly] + public class GasFilterVisualizer : AppearanceVisualizer + { + private string _filterEnabledState = default!; + + public override void LoadData(YamlMappingNode node) + { + base.LoadData(node); + var serializer = YamlObjectSerializer.NewReader(node); + serializer.DataField(ref _filterEnabledState, "filterEnabledState", "gasFilterOn"); + } + + public override void InitializeEntity(IEntity entity) + { + base.InitializeEntity(entity); + + if (!entity.TryGetComponent(out var sprite)) return; + + sprite.LayerMapReserveBlank(Layer.FilterEnabled); + var filterEnabledLayer = sprite.LayerMapGet(Layer.FilterEnabled); + sprite.LayerSetState(filterEnabledLayer, _filterEnabledState); + } + + public override void OnChangeData(AppearanceComponent component) + { + base.OnChangeData(component); + + if (!component.Owner.TryGetComponent(out var sprite)) return; + if (!component.TryGetData(FilterVisuals.VisualState, out FilterVisualState filterVisualState)) return; + + var filterEnabledLayer = sprite.LayerMapGet(Layer.FilterEnabled); + sprite.LayerSetVisible(filterEnabledLayer, filterVisualState.Enabled); + } + + public enum Layer : byte + { + FilterEnabled, + } + } +} diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/GasFilterComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/GasFilterComponent.cs index 70bbc7bbb6..8a6cd18f1d 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/GasFilterComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/GasFilterComponent.cs @@ -148,7 +148,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping.Filters private void UpdateAppearance() { - _appearance?.SetData(FilterVisuals.VisualState, new FilterVisualState()); + _appearance?.SetData(FilterVisuals.VisualState, new FilterVisualState(FilterEnabled)); } private void SetPipes() diff --git a/Content.Shared/GameObjects/Components/Atmos/SharedFilterComponent.cs b/Content.Shared/GameObjects/Components/Atmos/SharedFilterComponent.cs index 8308d30cbb..11d7e9972a 100644 --- a/Content.Shared/GameObjects/Components/Atmos/SharedFilterComponent.cs +++ b/Content.Shared/GameObjects/Components/Atmos/SharedFilterComponent.cs @@ -1,3 +1,4 @@ +#nullable enable using System; using Robust.Shared.Serialization; @@ -12,6 +13,11 @@ namespace Content.Shared.GameObjects.Components.Atmos [Serializable, NetSerializable] public class FilterVisualState { + public bool Enabled { get; } + public FilterVisualState(bool enabled) + { + Enabled = enabled; + } } } diff --git a/Resources/Prototypes/Entities/Constructible/Ground/gasfilters.yml b/Resources/Prototypes/Entities/Constructible/Ground/gasfilters.yml index fc84458bdc..ce2d6dafd5 100644 --- a/Resources/Prototypes/Entities/Constructible/Ground/gasfilters.yml +++ b/Resources/Prototypes/Entities/Constructible/Ground/gasfilters.yml @@ -9,9 +9,6 @@ - type: Physics - type: SnapGrid offset: Center - - type: Sprite - sprite: Constructible/Atmos/pipeitems.rsi - state: scrubber - type: Damageable resistances: metallicResistances - type: Destructible @@ -28,11 +25,11 @@ description: It filters gases. components: - type: Sprite - sprite: Constructible/Atmos/pipe.rsi - state: pipeTJunction2 + sprite: Constructible/Atmos/gasfilter.rsi + state: gasFilter - type: Icon - sprite: Constructible/Atmos/pipe.rsi - state: pipeTJunction2 + sprite: Constructible/Atmos/gasfilter.rsi + state: gasFilter - type: NodeContainer nodes: - !type:PipeNode @@ -48,3 +45,7 @@ inletDirection: South filterOutletDirection: East outletDirection: North + - type: Appearance + visuals: + - type: GasFilterVisualizer + filerEnabledState: gasFilterOn \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml b/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml index 31c2f366af..d79302849c 100644 --- a/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml +++ b/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml @@ -39,10 +39,10 @@ inletDirection: West outletDirection: East - type: Sprite - state: pumpPressure2 + state: pumpPressure - type: Icon - state: pumpPressure2 + state: pumpPressure - type: Appearance visuals: - type: PumpVisualizer - pumpEnabledState: pumpPressure2On + pumpEnabledState: pumpPressureOn diff --git a/Resources/Textures/Constructible/Atmos/gasfilter.rsi/gasFilter.png b/Resources/Textures/Constructible/Atmos/gasfilter.rsi/gasFilter.png new file mode 100644 index 0000000000..0735d1b17b Binary files /dev/null and b/Resources/Textures/Constructible/Atmos/gasfilter.rsi/gasFilter.png differ diff --git a/Resources/Textures/Constructible/Atmos/gasfilter.rsi/gasFilterOn.png b/Resources/Textures/Constructible/Atmos/gasfilter.rsi/gasFilterOn.png new file mode 100644 index 0000000000..9688ee0b37 Binary files /dev/null and b/Resources/Textures/Constructible/Atmos/gasfilter.rsi/gasFilterOn.png differ diff --git a/Resources/Textures/Constructible/Atmos/gasfilter.rsi/meta.json b/Resources/Textures/Constructible/Atmos/gasfilter.rsi/meta.json new file mode 100644 index 0000000000..f715b8af46 --- /dev/null +++ b/Resources/Textures/Constructible/Atmos/gasfilter.rsi/meta.json @@ -0,0 +1 @@ +{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/tgstation/tgstation at commit 57cd1d59ca019dd0e7811ac451f295f818e573da", "states": [{"name": "gasFilter", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "gasFilterOn", "directions": 4, "delays": [[0.2, 0.2, 0.2, 0.2], [0.2, 0.2, 0.2, 0.2], [0.2, 0.2, 0.2, 0.2], [0.2, 0.2, 0.2, 0.2]]}]} \ No newline at end of file diff --git a/Resources/Textures/Constructible/Atmos/pump.rsi/meta.json b/Resources/Textures/Constructible/Atmos/pump.rsi/meta.json index eafa97cacb..5ad04657cb 100644 --- a/Resources/Textures/Constructible/Atmos/pump.rsi/meta.json +++ b/Resources/Textures/Constructible/Atmos/pump.rsi/meta.json @@ -1 +1 @@ -{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/tgstation/tgstation at commit 57cd1d59ca019dd0e7811ac451f295f818e573da", "states": [{"name": "pumpDigitalValve2", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpManualValve2", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpPassiveGate2", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpPassiveGate2On", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpPressure2", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpPressure2On", "directions": 4, "delays": [[0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1]]}, {"name": "pumpVolume2", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpVolume2On", "directions": 4, "delays": [[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]]}]} \ No newline at end of file +{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/tgstation/tgstation at commit 57cd1d59ca019dd0e7811ac451f295f818e573da", "states": [{"name": "pumpDigitalValve", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpManualValve", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpPassiveGate", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpPassiveGateOn", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpPressure", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpPressureOn", "directions": 4, "delays": [[0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1]]}, {"name": "pumpVolume", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "pumpVolumeOn", "directions": 4, "delays": [[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]]}]} \ No newline at end of file diff --git a/Resources/Textures/Constructible/Atmos/pump.rsi/pumpDigitalValve2.png b/Resources/Textures/Constructible/Atmos/pump.rsi/pumpDigitalValve.png similarity index 100% rename from Resources/Textures/Constructible/Atmos/pump.rsi/pumpDigitalValve2.png rename to Resources/Textures/Constructible/Atmos/pump.rsi/pumpDigitalValve.png diff --git a/Resources/Textures/Constructible/Atmos/pump.rsi/pumpManualValve2.png b/Resources/Textures/Constructible/Atmos/pump.rsi/pumpManualValve.png similarity index 100% rename from Resources/Textures/Constructible/Atmos/pump.rsi/pumpManualValve2.png rename to Resources/Textures/Constructible/Atmos/pump.rsi/pumpManualValve.png diff --git a/Resources/Textures/Constructible/Atmos/pump.rsi/pumpPassiveGate2.png b/Resources/Textures/Constructible/Atmos/pump.rsi/pumpPassiveGate.png similarity index 100% rename from Resources/Textures/Constructible/Atmos/pump.rsi/pumpPassiveGate2.png rename to Resources/Textures/Constructible/Atmos/pump.rsi/pumpPassiveGate.png diff --git a/Resources/Textures/Constructible/Atmos/pump.rsi/pumpPassiveGate2On.png b/Resources/Textures/Constructible/Atmos/pump.rsi/pumpPassiveGateOn.png similarity index 100% rename from Resources/Textures/Constructible/Atmos/pump.rsi/pumpPassiveGate2On.png rename to Resources/Textures/Constructible/Atmos/pump.rsi/pumpPassiveGateOn.png diff --git a/Resources/Textures/Constructible/Atmos/pump.rsi/pumpPressure2.png b/Resources/Textures/Constructible/Atmos/pump.rsi/pumpPressure.png similarity index 100% rename from Resources/Textures/Constructible/Atmos/pump.rsi/pumpPressure2.png rename to Resources/Textures/Constructible/Atmos/pump.rsi/pumpPressure.png diff --git a/Resources/Textures/Constructible/Atmos/pump.rsi/pumpPressure2On.png b/Resources/Textures/Constructible/Atmos/pump.rsi/pumpPressureOn.png similarity index 100% rename from Resources/Textures/Constructible/Atmos/pump.rsi/pumpPressure2On.png rename to Resources/Textures/Constructible/Atmos/pump.rsi/pumpPressureOn.png diff --git a/Resources/Textures/Constructible/Atmos/pump.rsi/pumpVolume2.png b/Resources/Textures/Constructible/Atmos/pump.rsi/pumpVolume.png similarity index 100% rename from Resources/Textures/Constructible/Atmos/pump.rsi/pumpVolume2.png rename to Resources/Textures/Constructible/Atmos/pump.rsi/pumpVolume.png diff --git a/Resources/Textures/Constructible/Atmos/pump.rsi/pumpVolume2On.png b/Resources/Textures/Constructible/Atmos/pump.rsi/pumpVolumeOn.png similarity index 100% rename from Resources/Textures/Constructible/Atmos/pump.rsi/pumpVolume2On.png rename to Resources/Textures/Constructible/Atmos/pump.rsi/pumpVolumeOn.png