From f01a50012e767e4aca548269ae79dde761e08f91 Mon Sep 17 00:00:00 2001 From: py01 <60152240+collinlunn@users.noreply.github.com> Date: Sun, 18 Oct 2020 04:13:06 -0600 Subject: [PATCH] Vent and Siphon visualizer and icon fixes (#2288) * Half pipes * PipeVisualizer pipeRSI field * Vent and Siphon visualizer fixes Co-authored-by: py01 --- .../Components/Atmos/PipeVisualizer.cs | 29 ++++++++++++++++++ .../Components/Atmos/SiphonVisualizer.cs | 22 +++++++------ .../Components/Atmos/VentVisualizer.cs | 22 +++++++------ .../Components/Atmos/SharedPipeComponent.cs | 6 ++++ .../Entities/Constructible/Ground/pipes.yml | 16 ++++++++-- .../Constructible/Atmos/pipe.rsi/meta.json | 18 +++++++++++ .../Atmos/pipe.rsi/pipeHalf2.png | Bin 0 -> 469 bytes 7 files changed, 93 insertions(+), 20 deletions(-) create mode 100644 Resources/Textures/Constructible/Atmos/pipe.rsi/pipeHalf2.png diff --git a/Content.Client/GameObjects/Components/Atmos/PipeVisualizer.cs b/Content.Client/GameObjects/Components/Atmos/PipeVisualizer.cs index 7bd00e4fac..2262ea1c7e 100644 --- a/Content.Client/GameObjects/Components/Atmos/PipeVisualizer.cs +++ b/Content.Client/GameObjects/Components/Atmos/PipeVisualizer.cs @@ -2,20 +2,49 @@ 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.Interfaces.ResourceManagement; +using Robust.Client.ResourceManagement; +using Robust.Shared.GameObjects.Components.Renderable; using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Log; +using Robust.Shared.Utility; +using YamlDotNet.RepresentationModel; namespace Content.Client.GameObjects.Components.Atmos { [UsedImplicitly] public class PipeVisualizer : AppearanceVisualizer { + private RSI _pipeRSI; + + public override void LoadData(YamlMappingNode node) + { + base.LoadData(node); + + var rsiString = node.GetNode("pipeRSI").ToString(); + var rsiPath = SharedSpriteComponent.TextureRoot / rsiString; + try + { + var resourceCache = IoCManager.Resolve(); + var resource = resourceCache.GetResource(rsiPath); + _pipeRSI = resource.RSI; + } + catch (Exception e) + { + Logger.ErrorS("go.ventvisualizer", "Unable to load RSI '{0}'. Trace:\n{1}", rsiPath, e); + } + } + public override void InitializeEntity(IEntity entity) { base.InitializeEntity(entity); if (!entity.TryGetComponent(out ISpriteComponent sprite)) return; sprite.LayerMapReserveBlank(Layer.PipeBase); var pipeBaseLayer = sprite.LayerMapGet(Layer.PipeBase); + sprite.LayerSetRSI(pipeBaseLayer, _pipeRSI); sprite.LayerSetVisible(pipeBaseLayer, true); } diff --git a/Content.Client/GameObjects/Components/Atmos/SiphonVisualizer.cs b/Content.Client/GameObjects/Components/Atmos/SiphonVisualizer.cs index bdee4169dc..fa660f0ea0 100644 --- a/Content.Client/GameObjects/Components/Atmos/SiphonVisualizer.cs +++ b/Content.Client/GameObjects/Components/Atmos/SiphonVisualizer.cs @@ -11,6 +11,7 @@ using Robust.Shared.Utility; using System; using Content.Shared.GameObjects.Components.Atmos; using YamlDotNet.RepresentationModel; +using Robust.Shared.Interfaces.GameObjects; namespace Content.Client.GameObjects.Components.Atmos { @@ -37,23 +38,26 @@ namespace Content.Client.GameObjects.Components.Atmos } } + public override void InitializeEntity(IEntity entity) + { + base.InitializeEntity(entity); + if (!entity.TryGetComponent(out ISpriteComponent sprite)) return; + sprite.LayerMapReserveBlank(Layer.SiphonBase); + var pipeBaseLayer = sprite.LayerMapGet(Layer.SiphonBase); + sprite.LayerSetRSI(pipeBaseLayer, _siphonRSI); + sprite.LayerSetVisible(pipeBaseLayer, true); + } + public override void OnChangeData(AppearanceComponent component) { base.OnChangeData(component); - if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) - { - return; - } - if (!component.TryGetData(SiphonVisuals.VisualState, out SiphonVisualState siphonVisualState)) - { - return; - } + if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) return; + if (!component.TryGetData(SiphonVisuals.VisualState, out SiphonVisualState siphonVisualState)) return; var siphonBaseState = "scrub"; siphonBaseState += siphonVisualState.SiphonEnabled ? "On" : "Off"; - sprite.LayerMapReserveBlank(Layer.SiphonBase); var baseSiphonLayer = sprite.LayerMapGet(Layer.SiphonBase); sprite.LayerSetRSI(baseSiphonLayer, _siphonRSI); sprite.LayerSetState(baseSiphonLayer, siphonBaseState); diff --git a/Content.Client/GameObjects/Components/Atmos/VentVisualizer.cs b/Content.Client/GameObjects/Components/Atmos/VentVisualizer.cs index 04c9bd2681..6693907aab 100644 --- a/Content.Client/GameObjects/Components/Atmos/VentVisualizer.cs +++ b/Content.Client/GameObjects/Components/Atmos/VentVisualizer.cs @@ -11,6 +11,7 @@ using Robust.Shared.Utility; using System; using Content.Shared.GameObjects.Components.Atmos; using YamlDotNet.RepresentationModel; +using Robust.Shared.Interfaces.GameObjects; namespace Content.Client.GameObjects.Components.Atmos { @@ -37,23 +38,26 @@ namespace Content.Client.GameObjects.Components.Atmos } } + public override void InitializeEntity(IEntity entity) + { + base.InitializeEntity(entity); + if (!entity.TryGetComponent(out ISpriteComponent sprite)) return; + sprite.LayerMapReserveBlank(Layer.VentBase); + var pipeBaseLayer = sprite.LayerMapGet(Layer.VentBase); + sprite.LayerSetRSI(pipeBaseLayer, _ventRSI); + sprite.LayerSetVisible(pipeBaseLayer, true); + } + public override void OnChangeData(AppearanceComponent component) { base.OnChangeData(component); - if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) - { - return; - } - if (!component.TryGetData(VentVisuals.VisualState, out VentVisualState ventVisualState)) - { - return; - } + if (!component.Owner.TryGetComponent(out ISpriteComponent sprite)) return; + if (!component.TryGetData(VentVisuals.VisualState, out VentVisualState ventVisualState)) return; var ventBaseState = "vent"; ventBaseState += ventVisualState.VentEnabled ? "On" : "Off"; - sprite.LayerMapReserveBlank(Layer.VentBase); var baseVentLayer = sprite.LayerMapGet(Layer.VentBase); sprite.LayerSetRSI(baseVentLayer, _ventRSI); sprite.LayerSetState(baseVentLayer, ventBaseState); diff --git a/Content.Shared/GameObjects/Components/Atmos/SharedPipeComponent.cs b/Content.Shared/GameObjects/Components/Atmos/SharedPipeComponent.cs index 4d0b5ffce8..3e32da53ba 100644 --- a/Content.Shared/GameObjects/Components/Atmos/SharedPipeComponent.cs +++ b/Content.Shared/GameObjects/Components/Atmos/SharedPipeComponent.cs @@ -57,6 +57,7 @@ namespace Content.Shared.GameObjects.Components.Atmos public enum PipeShape { + Half, Straight, Bend, TJunction, @@ -126,6 +127,11 @@ namespace Content.Shared.GameObjects.Components.Atmos { return pipeDirection switch { + PipeDirection.North => PipeShape.Half, + PipeDirection.South => PipeShape.Half, + PipeDirection.East => PipeShape.Half, + PipeDirection.West => PipeShape.Half, + PipeDirection.Lateral => PipeShape.Straight, PipeDirection.Longitudinal => PipeShape.Straight, diff --git a/Resources/Prototypes/Entities/Constructible/Ground/pipes.yml b/Resources/Prototypes/Entities/Constructible/Ground/pipes.yml index 09be1aab5c..d09cfc373e 100644 --- a/Resources/Prototypes/Entities/Constructible/Ground/pipes.yml +++ b/Resources/Prototypes/Entities/Constructible/Ground/pipes.yml @@ -13,14 +13,26 @@ offset: Center - type: Destructible thresholdvalue: 100 - - type: Sprite - sprite: Constructible/Atmos/pipe.rsi - type: Appearance visuals: - type: PipeVisualizer + pipeRSI: Constructible/Atmos/pipe.rsi - type: Icon sprite: Constructible/Atmos/pipe.rsi +- type: entity + parent: PipeBase + id: PipeHalf + suffix: Half + components: + - type: NodeContainer + nodes: + - !type:PipeNode + nodeGroupID: Pipe + pipeDirection: North + - type: Icon + state: pipeHalf2 + - type: entity parent: PipeBase id: PipeStraight diff --git a/Resources/Textures/Constructible/Atmos/pipe.rsi/meta.json b/Resources/Textures/Constructible/Atmos/pipe.rsi/meta.json index 339b1595b0..a0d9b3276c 100644 --- a/Resources/Textures/Constructible/Atmos/pipe.rsi/meta.json +++ b/Resources/Textures/Constructible/Atmos/pipe.rsi/meta.json @@ -25,6 +25,24 @@ ] ] }, + { + "name":"pipeHalf2", + "directions":4, + "delays":[ + [ + 1.0 + ], + [ + 1.0 + ], + [ + 1.0 + ], + [ + 1.0 + ] + ] + }, { "name":"pipeBend2", "directions":4, diff --git a/Resources/Textures/Constructible/Atmos/pipe.rsi/pipeHalf2.png b/Resources/Textures/Constructible/Atmos/pipe.rsi/pipeHalf2.png new file mode 100644 index 0000000000000000000000000000000000000000..90ef0405e64ac9ea43e9e0b01b440d4a2783a5ca GIT binary patch literal 469 zcmV;`0V@89P)4<@xAPdP2Jd!u?2(APVkdORL=v)Sm-xr#9t=8@|F%CZCi#25$9;W_}-&nrKKFnA8v0i=`w zEcgnrZ{DtiAzTNL^TCbl0M_d@fCWDTL<9h^TCE1p;W~i({SE-=x^Cu`5D^g(5iP^_ zQu1^A7VEV6E(8Zvp%HvjYl`Mkz(@jLsw1tuPT05fKp)4KzuU(KL-#Rn@n} zB7zVCVvGZGd#u%I)+_#2uN@AD{Dr+RNdVjJ7Ij^t z>pF-CVvHz?0wMxc{c(_D|MUtW^slFs5JKq3+L$R!62SR}@q9j~ zSk_CE+*fVezI|3`ePT)ps@gv*tZ=nw$?bOY+q@DH5fKp)(LeJ6lQD~IG?oa?00000 LNkvXXu0mjfVIk82 literal 0 HcmV?d00001