From 178931e54b7ec24a2dfc4432d9b03c264947e2e9 Mon Sep 17 00:00:00 2001 From: py01 <60152240+collinlunn@users.noreply.github.com> Date: Mon, 31 Aug 2020 04:33:05 -0600 Subject: [PATCH] Pump visuals (#1960) * Pipe sprites * pipe copyright * SharedPipeComponent * Pipe Visualizer draft * missing longitudinal pipe sprites * expanded rsi states * pipe prototype fixes * Fixed pipe visualizer * PressurePump and VolumePump * VolumePump fix * PressurePump fix * Shared pump # Conflicts: # Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs # Content.Server/GameObjects/Components/NodeContainer/Nodes/PipeNode.cs * PumpVisualizer Draft * ConduitLayer enum * PipeVisualizer update * halfpipe sprites * pumpvisualizer simplification * yaml unneeded proto removal * pump visualizer draft 2 * Pump overlays * pump rsi name * merge fix * PumpVisuals ConduitLayer * merge fix Co-authored-by: py01 --- .../Components/Atmos/PipeVisualizer.cs | 3 +- .../Components/Atmos/PumpVisualizer.cs | 70 ++++++++++++++++++ .../Atmos/Piping/Pumps/BasePumpComponent.cs | 11 +++ .../GameObjects/Atmos/SharedPumpComponent.cs | 29 ++++++++ .../Entities/Constructible/Ground/pumps.yml | 9 ++- .../Atmos/pressurepump.rsi/meta.json | 31 ++++++++ .../Atmos/pressurepump.rsi/pumpEast2West2.png | Bin 0 -> 281 bytes .../pressurepump.rsi/pumpNorth2South2.png | Bin 0 -> 332 bytes .../pressurepump.rsi/pumpSouth2North2.png | Bin 0 -> 320 bytes .../Atmos/pressurepump.rsi/pumpWest2East2.png | Bin 0 -> 272 bytes 10 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 Content.Client/GameObjects/Components/Atmos/PumpVisualizer.cs create mode 100644 Content.Shared/GameObjects/Atmos/SharedPumpComponent.cs create mode 100644 Resources/Textures/Constructible/Atmos/pressurepump.rsi/meta.json create mode 100644 Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpEast2West2.png create mode 100644 Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpNorth2South2.png create mode 100644 Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpSouth2North2.png create mode 100644 Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpWest2East2.png 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 0000000000000000000000000000000000000000..dc07973864d14a63d8a72dec3ff506bad1385d12 GIT binary patch literal 281 zcmV+!0p|XRP)FX16ey7>XLrl4*uP8W6Z z(EBY1$A@$h5-6pV`tNps35!UG&3f;n){Y)PM8e_l%zl3tm7k_5YKWWb#>v`nvUYV+ z5ediR3wfS1JBPKF**S`$V0I2;46}1oRrOtC{Td)mQ<5ZEZT|H5K$d0P8v{UH*8nt4 z13=rh0F-69sxfY_8_Ti~!p{YG?{}|n@8NR!F7f#&HCo>pB4XzF*ZCo41pw6o!A5&N_f0OP3BAdWG}?#VxH3Hh9P}TIf+c=mcJ!3wSUTWNZ+a8sfPbtRe2E zP8nLd_zhAB`bNS3^zrzG0FTGxaSWq`IOpc?nbw*#YjKEkZo)7G03=C*wr$Zg4T_>5 zNn9@toaltWn-Bnib(T@b&;{06_G<&y1b&^AR^M&$!=g@Hq?^$B`^>wKSl$W@Wj< z_k6^D+~aWgLRs#}e*qcJxp{hgF#ml_RwbNWeld`X^RZf)AP6u`6K<6v&sqEmPB6y6 enBC%gE|VX-$8A7IW5JyO0000MhJufhVp@HV6e(mw0t2B(Y?I` z05(~s8KW2YIy8=B7-L|qonD|}#w+u;%;W;w;}KC5p)5`yFm5;k|RD)&>Li%O_sfaMK0h0EMhvh3y95h7CXOY zn&D%Zc@LCQO8s|%w9y!|NPDMg66cB;Pd zNz;_Udz^C&-jgH=mrK3b*u%Ny;oN46;sLTOTh*$n04U26fTAb>I9f{_$9$eot0BTL zB#NR W>r71yHG6^p0000