diff --git a/Content.Client/GameObjects/Components/Atmos/PipeVisualizer.cs b/Content.Client/GameObjects/Components/Atmos/PipeVisualizer.cs index 7d057e0766..add360dcce 100644 --- a/Content.Client/GameObjects/Components/Atmos/PipeVisualizer.cs +++ b/Content.Client/GameObjects/Components/Atmos/PipeVisualizer.cs @@ -1,8 +1,8 @@ using Content.Shared.GameObjects.Components.Atmos; using JetBrains.Annotations; using Robust.Client.GameObjects; -using Robust.Client.Graphics; using Robust.Client.Interfaces.GameObjects.Components; +using Robust.Client.Graphics; using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.ResourceManagement; using Robust.Shared.GameObjects.Components.Renderable; @@ -10,7 +10,6 @@ using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Utility; using System; -using System.Collections.Generic; using YamlDotNet.RepresentationModel; namespace Content.Client.GameObjects.Components.Atmos diff --git a/Content.Client/GameObjects/Components/Atmos/PumpVisualizer.cs b/Content.Client/GameObjects/Components/Atmos/PumpVisualizer.cs new file mode 100644 index 0000000000..42ea6bf6ea --- /dev/null +++ b/Content.Client/GameObjects/Components/Atmos/PumpVisualizer.cs @@ -0,0 +1,70 @@ +using Content.Shared.GameObjects.Atmos; +using JetBrains.Annotations; +using Robust.Client.GameObjects; +using Robust.Client.Graphics; +using Robust.Client.Interfaces.GameObjects.Components; +using Robust.Client.Interfaces.ResourceManagement; +using Robust.Client.ResourceManagement; +using Robust.Shared.GameObjects.Components.Renderable; +using Robust.Shared.IoC; +using Robust.Shared.Log; +using Robust.Shared.Utility; +using System; +using YamlDotNet.RepresentationModel; + +namespace Content.Client.GameObjects.Components.Disposal +{ + [UsedImplicitly] + public class PumpVisualizer : AppearanceVisualizer + { + private RSI _pumpRSI; + + public override void LoadData(YamlMappingNode node) + { + base.LoadData(node); + + var rsiString = node.GetNode("pumpRSI").ToString(); + var rsiPath = SharedSpriteComponent.TextureRoot / rsiString; + try + { + var resourceCache = IoCManager.Resolve(); + var resource = resourceCache.GetResource(rsiPath); + _pumpRSI = resource.RSI; + } + catch (Exception e) + { + Logger.ErrorS("go.pumpvisualizer", "Unable to load RSI '{0}'. Trace:\n{1}", rsiPath, e); + } + } + + public override void OnChangeData(AppearanceComponent component) + { + base.OnChangeData(component); + + if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) + { + return; + } + if (!component.TryGetData(PumpVisuals.VisualState, out PumpVisualState pumpVisualState)) + { + return; + } + var pumpBaseState = "pump"; + pumpBaseState += pumpVisualState.InletDirection.ToString(); + pumpBaseState += ((int) pumpVisualState.InletConduitLayer).ToString(); + pumpBaseState += pumpVisualState.OutletDirection.ToString(); + pumpBaseState += ((int) pumpVisualState.OutletConduitLayer).ToString(); + + sprite.LayerMapReserveBlank(Layer.PumpBase); + var basePumpLayer = sprite.LayerMapGet(Layer.PumpBase); + sprite.LayerSetRSI(basePumpLayer, _pumpRSI); + sprite.LayerSetState(basePumpLayer, pumpBaseState); + sprite.LayerSetVisible(basePumpLayer, true); + } + + private enum Layer + { + PumpBase + } + } +} diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs index 23e9f63c33..1556c9a62c 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs @@ -2,6 +2,8 @@ using Content.Server.GameObjects.Components.NodeContainer; using Content.Server.GameObjects.Components.NodeContainer.Nodes; using Content.Shared.GameObjects.Components.Atmos; +using Content.Shared.GameObjects.Atmos; +using Robust.Server.GameObjects; using Robust.Shared.Log; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; @@ -32,6 +34,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping [ViewVariables] private PipeNode _outletPipe; + private AppearanceComponent _appearance; + public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); @@ -57,6 +61,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping Logger.Error($"{typeof(BasePumpComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}."); return; } + Owner.TryGetComponent(out _appearance); + UpdateAppearance(); } public override void Update() @@ -65,5 +71,10 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping } protected abstract void PumpGas(GasMixture inletGas, GasMixture outletGas); + + private void UpdateAppearance() + { + _appearance?.SetData(PumpVisuals.VisualState, new PumpVisualState(_inletDirection, _outletDirection, _inletPipe.ConduitLayer, _outletPipe.ConduitLayer)); + } } } diff --git a/Content.Shared/GameObjects/Atmos/SharedPumpComponent.cs b/Content.Shared/GameObjects/Atmos/SharedPumpComponent.cs new file mode 100644 index 0000000000..d4f304e53e --- /dev/null +++ b/Content.Shared/GameObjects/Atmos/SharedPumpComponent.cs @@ -0,0 +1,29 @@ +using Content.Shared.GameObjects.Components.Atmos; +using Robust.Shared.Serialization; +using System; + +namespace Content.Shared.GameObjects.Atmos +{ + [Serializable, NetSerializable] + public enum PumpVisuals + { + VisualState + } + + [Serializable, NetSerializable] + public class PumpVisualState + { + public readonly PipeDirection InletDirection; + public readonly PipeDirection OutletDirection; + public readonly ConduitLayer InletConduitLayer; + public readonly ConduitLayer OutletConduitLayer; + + public PumpVisualState(PipeDirection inletDirection, PipeDirection outletDirection, ConduitLayer inletConduitLayer, ConduitLayer outletConduitLayer) + { + InletDirection = inletDirection; + OutletDirection = outletDirection; + InletConduitLayer = inletConduitLayer; + OutletConduitLayer = outletConduitLayer; + } + } +} diff --git a/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml b/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml index d1f2ac0b5c..ff727b63f6 100644 --- a/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml +++ b/Resources/Prototypes/Entities/Constructible/Ground/pumps.yml @@ -12,7 +12,12 @@ - type: Icon texture: Constructible/Power/eightdirwire.png - type: Sprite - sprite: Constructible/Power/mv_cable.rsi + - type: Appearance + visuals: + - type: PipeVisualizer + pipeRSI: Constructible/Atmos/pipe.rsi + - type: PumpVisualizer + pumpRSI: Constructible/Atmos/pressurepump.rsi - type: Destructible thresholdvalue: 100 @@ -21,8 +26,6 @@ parent: PumpBase id: NorthwardLongitudinalPump components: - - type: Sprite - state: mvcable_3 - type: NodeContainer nodes: - !type:PipeNode diff --git a/Resources/Textures/Constructible/Atmos/pressurepump.rsi/meta.json b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/meta.json new file mode 100644 index 0000000000..f950406db6 --- /dev/null +++ b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/meta.json @@ -0,0 +1,31 @@ +{ + "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":"pumpEast2West2", + "directions":1, + "delays":[ [ 1.0 ] ] + }, + { + "name":"pumpNorth2South2", + "directions":1, + "delays":[ [ 1.0 ] ] + }, + { + "name":"pumpSouth2North2", + "directions":1, + "delays":[ [ 1.0 ] ] + }, + { + "name":"pumpWest2East2", + "directions":1, + "delays":[ [ 1.0 ] ] + } + ] +} \ No newline at end of file diff --git a/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpEast2West2.png b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpEast2West2.png new file mode 100644 index 0000000000..dc07973864 Binary files /dev/null and b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpEast2West2.png differ diff --git a/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpNorth2South2.png b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpNorth2South2.png new file mode 100644 index 0000000000..3f26d407ea Binary files /dev/null and b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpNorth2South2.png differ diff --git a/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpSouth2North2.png b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpSouth2North2.png new file mode 100644 index 0000000000..d805b9df59 Binary files /dev/null and b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpSouth2North2.png differ diff --git a/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpWest2East2.png b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpWest2East2.png new file mode 100644 index 0000000000..789ad70f39 Binary files /dev/null and b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpWest2East2.png differ