Filter sprites & visualizer (#3008)
Co-authored-by: py01 <pyronetics01@gmail.com>
@@ -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<ISpriteComponent>(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<ISpriteComponent>(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,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
After Width: | Height: | Size: 825 B |
|
After Width: | Height: | Size: 6.3 KiB |
@@ -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]]}]}
|
||||
@@ -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]]}]}
|
||||
{"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]]}]}
|
||||
|
Before Width: | Height: | Size: 982 B After Width: | Height: | Size: 982 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 119 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |