From 4d43a15cba9ba2851d6b740ea072175fbef3582e Mon Sep 17 00:00:00 2001 From: py01 <60152240+collinlunn@users.noreply.github.com> Date: Mon, 31 Aug 2020 16:29:53 -0600 Subject: [PATCH] Pump enabled animation (#1973) * Pump enabled animation * naming fixes Co-authored-by: py01 --- .../Components/Atmos/PumpVisualizer.cs | 19 +++++++++++++++-- .../Atmos/Piping/Pumps/BasePumpComponent.cs | 20 +++++++++++++++++- .../GameObjects/Atmos/SharedPumpComponent.cs | 4 +++- .../Atmos/pressurepump.rsi/meta.json | 20 ++++++++++++++++++ .../pumpEnabledEast2West2.png | Bin 0 -> 386 bytes .../pumpEnabledNorth2South2.png | Bin 0 -> 896 bytes .../pumpEnabledSouth2North2.png | Bin 0 -> 823 bytes .../pumpEnabledWest2East2.png | Bin 0 -> 408 bytes 8 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpEnabledEast2West2.png create mode 100644 Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpEnabledNorth2South2.png create mode 100644 Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpEnabledSouth2North2.png create mode 100644 Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpEnabledWest2East2.png diff --git a/Content.Client/GameObjects/Components/Atmos/PumpVisualizer.cs b/Content.Client/GameObjects/Components/Atmos/PumpVisualizer.cs index 42ea6bf6ea..a4b8c9d3dd 100644 --- a/Content.Client/GameObjects/Components/Atmos/PumpVisualizer.cs +++ b/Content.Client/GameObjects/Components/Atmos/PumpVisualizer.cs @@ -12,7 +12,7 @@ using Robust.Shared.Utility; using System; using YamlDotNet.RepresentationModel; -namespace Content.Client.GameObjects.Components.Disposal +namespace Content.Client.GameObjects.Components.Atmos { [UsedImplicitly] public class PumpVisualizer : AppearanceVisualizer @@ -60,11 +60,26 @@ namespace Content.Client.GameObjects.Components.Disposal sprite.LayerSetRSI(basePumpLayer, _pumpRSI); sprite.LayerSetState(basePumpLayer, pumpBaseState); sprite.LayerSetVisible(basePumpLayer, true); + + + + var pumpEnabledAnimationState = "pumpEnabled"; + pumpEnabledAnimationState += pumpVisualState.InletDirection.ToString(); + pumpEnabledAnimationState += ((int) pumpVisualState.InletConduitLayer).ToString(); + pumpEnabledAnimationState += pumpVisualState.OutletDirection.ToString(); + pumpEnabledAnimationState += ((int) pumpVisualState.OutletConduitLayer).ToString(); + + sprite.LayerMapReserveBlank(Layer.PumpEnabled); + var pumpEnabledAnimationLayer = sprite.LayerMapGet(Layer.PumpEnabled); + sprite.LayerSetRSI(pumpEnabledAnimationLayer, _pumpRSI); + sprite.LayerSetState(pumpEnabledAnimationLayer, pumpEnabledAnimationState); + sprite.LayerSetVisible(pumpEnabledAnimationLayer, pumpVisualState.PumpEnabled); } private enum Layer { - PumpBase + PumpBase, + PumpEnabled, } } } diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs index 1556c9a62c..24a44ae7d8 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Pumps/BasePumpComponent.cs @@ -16,6 +16,21 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping /// public abstract class BasePumpComponent : PipeNetDeviceComponent { + /// + /// If the pump is currently pumping. + /// + [ViewVariables(VVAccess.ReadWrite)] + public bool PumpEnabled + { + get => _pumpEnabled; + set + { + _pumpEnabled = value; + UpdateAppearance(); + } + } + private bool _pumpEnabled = true; + /// /// Needs to be same as that of a on this entity. /// @@ -67,6 +82,9 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping public override void Update() { + if (!PumpEnabled) + return; + PumpGas(_inletPipe.Air, _outletPipe.Air); } @@ -74,7 +92,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping private void UpdateAppearance() { - _appearance?.SetData(PumpVisuals.VisualState, new PumpVisualState(_inletDirection, _outletDirection, _inletPipe.ConduitLayer, _outletPipe.ConduitLayer)); + _appearance?.SetData(PumpVisuals.VisualState, new PumpVisualState(_inletDirection, _outletDirection, _inletPipe.ConduitLayer, _outletPipe.ConduitLayer, PumpEnabled)); } } } diff --git a/Content.Shared/GameObjects/Atmos/SharedPumpComponent.cs b/Content.Shared/GameObjects/Atmos/SharedPumpComponent.cs index d4f304e53e..8546d9d071 100644 --- a/Content.Shared/GameObjects/Atmos/SharedPumpComponent.cs +++ b/Content.Shared/GameObjects/Atmos/SharedPumpComponent.cs @@ -17,13 +17,15 @@ namespace Content.Shared.GameObjects.Atmos public readonly PipeDirection OutletDirection; public readonly ConduitLayer InletConduitLayer; public readonly ConduitLayer OutletConduitLayer; + public readonly bool PumpEnabled; - public PumpVisualState(PipeDirection inletDirection, PipeDirection outletDirection, ConduitLayer inletConduitLayer, ConduitLayer outletConduitLayer) + public PumpVisualState(PipeDirection inletDirection, PipeDirection outletDirection, ConduitLayer inletConduitLayer, ConduitLayer outletConduitLayer, bool pumpEnabled) { InletDirection = inletDirection; OutletDirection = outletDirection; InletConduitLayer = inletConduitLayer; OutletConduitLayer = outletConduitLayer; + PumpEnabled = pumpEnabled; } } } diff --git a/Resources/Textures/Constructible/Atmos/pressurepump.rsi/meta.json b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/meta.json index f950406db6..d8390a7ef9 100644 --- a/Resources/Textures/Constructible/Atmos/pressurepump.rsi/meta.json +++ b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/meta.json @@ -26,6 +26,26 @@ "name":"pumpWest2East2", "directions":1, "delays":[ [ 1.0 ] ] + }, + { + "name":"pumpEnabledEast2West2", + "directions":1, + "delays":[ [ 0.1, 0.1, 0.1, 0.1, 0.1 ] ] + }, + { + "name":"pumpEnabledNorth2South2", + "directions":1, + "delays":[ [ 0.1, 0.1, 0.1, 0.1, 0.1 ] ] + }, + { + "name":"pumpEnabledSouth2North2", + "directions":1, + "delays":[ [ 0.1, 0.1, 0.1, 0.1, 0.1 ] ] + }, + { + "name":"pumpEnabledWest2East2", + "directions":1, + "delays":[ [ 0.1, 0.1, 0.1, 0.1, 0.1 ] ] } ] } \ No newline at end of file diff --git a/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpEnabledEast2West2.png b/Resources/Textures/Constructible/Atmos/pressurepump.rsi/pumpEnabledEast2West2.png new file mode 100644 index 0000000000000000000000000000000000000000..4e2d4e1a78786d3372963633e23c250f811a52b8 GIT binary patch literal 386 zcmV-|0e$|7P)423lEn_^Lh2nzX)P`F0t5xUlH5*~uDZ9-&A~}nlhwOaADTmmqk&jFatW&lj5Qveo=MPWRJOV4)?s5#%ipfk#sBuSDaNs=T gk|arzBuUrd2NkDIlq4hyo*E2Pr2AjCl_MI4g%9`|hf`;3MAeShiWkw5%?03n1B zLI@#*5MQ;iJftW}`#rzqhZIF=^!4=t00svKv9z>=N~MC?*;!xy341NS zowX4&Jp~g}fC^}pBx@OF=`|A=H=zQk1U3KjyG&rkgn9(1fIa^J>w}t+gze5FZyC(t zJdB_Qcf^L(otKlpsKM>DVg2CC=ePmuFfsAx1_Zd8V9VbdH<0571mJjgp%>3Fhx5>k zBpmNK^x^|4`9@HKch5obqRv%^`2fsxKO&(`=!x@O4Y230BNBQFJyDjFKZQu>I`qUN zt~$&IFf=v?+wDNERN-oXJ^v_dcNn?S1xfk0VY~Clm9kuQm=7Rzxd3$~iukb%R|BjH zsa{0YEo9d^6pTp72lHkDcMF!}Kw#!MERH z_Iv&|MNt~JVmBNA`eBOleQZKnIOP+v2Qa^JG=RAsMS8`wv;Xp$zXuRP2qAyuv!S8K5hPyg0^4aJ zzsp4EV+4s4a`HuCK7g^~LvTlIl&<7N_S1a+t0B0ZHcDURE@7lm_6@);2R{gKdb zvhzh@-VYea9^5e>FJnGmUcN}QAFx}=o{yKE|6h>(;$`O(LU_@BfMm2EKnNj(Nb(Em WAlmf$*F6OQ0000v`iU!nDso+o?+Qvl`9HN7zfpmBv4ubXE>pPg7-}C~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