From 83d4a787eeb3a545731cdcfa5bda4529b10b1866 Mon Sep 17 00:00:00 2001 From: 08A Date: Sat, 4 Mar 2023 21:31:46 +0100 Subject: [PATCH] Add layers field to construction prototype (#14222) --- .../ConstructionPlacementHijack.cs | 12 +---- .../Construction/ConstructionSystem.cs | 12 +++-- .../Prototypes/ConstructionPrototype.cs | 7 +++ .../Recipes/Construction/utilities.yml | 50 +++++++++++++++++++ 4 files changed, 67 insertions(+), 14 deletions(-) diff --git a/Content.Client/Construction/ConstructionPlacementHijack.cs b/Content.Client/Construction/ConstructionPlacementHijack.cs index f6a7f4c624..e2e6ab6692 100644 --- a/Content.Client/Construction/ConstructionPlacementHijack.cs +++ b/Content.Client/Construction/ConstructionPlacementHijack.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using Content.Shared.Construction; using Content.Shared.Construction.Prototypes; using Robust.Client.Graphics; @@ -49,16 +50,7 @@ namespace Content.Client.Construction public override void StartHijack(PlacementManager manager) { base.StartHijack(manager); - - var frame = _prototype?.Icon.DirFrame0(); - if (frame == null) - { - manager.CurrentTextures = null; - } - else - { - manager.CurrentTextures = new List {frame}; - } + manager.CurrentTextures = _prototype?.Layers.Select(sprite => sprite.DirFrame0()).ToList(); } } } diff --git a/Content.Client/Construction/ConstructionSystem.cs b/Content.Client/Construction/ConstructionSystem.cs index e813882473..c16d533a2e 100644 --- a/Content.Client/Construction/ConstructionSystem.cs +++ b/Content.Client/Construction/ConstructionSystem.cs @@ -179,10 +179,14 @@ namespace Content.Client.Construction _ghosts.Add(comp.GhostId, comp); var sprite = EntityManager.GetComponent(ghost); sprite.Color = new Color(48, 255, 48, 128); - sprite.AddBlankLayer(0); // There is no way to actually check if this already exists, so we blindly insert a new one - sprite.LayerSetSprite(0, prototype.Icon); - sprite.LayerSetShader(0, "unshaded"); - sprite.LayerSetVisible(0, true); + + for (int i = 0; i < prototype.Layers.Count; i++) + { + sprite.AddBlankLayer(i); // There is no way to actually check if this already exists, so we blindly insert a new one + sprite.LayerSetSprite(i, prototype.Layers[i]); + sprite.LayerSetShader(i, "unshaded"); + sprite.LayerSetVisible(i, true); + } if (prototype.CanBuildInImpassable) EnsureComp(ghost).Arc = new(Math.Tau); diff --git a/Content.Shared/Construction/Prototypes/ConstructionPrototype.cs b/Content.Shared/Construction/Prototypes/ConstructionPrototype.cs index cb4bf5814d..84b0b8591a 100644 --- a/Content.Shared/Construction/Prototypes/ConstructionPrototype.cs +++ b/Content.Shared/Construction/Prototypes/ConstructionPrototype.cs @@ -46,6 +46,12 @@ namespace Content.Shared.Construction.Prototypes [DataField("icon")] public SpriteSpecifier Icon { get; } = SpriteSpecifier.Invalid; + /// + /// Texture paths used for the construction ghost. + /// + [DataField("layers")] + private List? _layers; + /// /// If you can start building or complete steps on impassable terrain. /// @@ -70,6 +76,7 @@ namespace Content.Shared.Construction.Prototypes public bool CanRotate { get; } = true; public IReadOnlyList Conditions => _conditions; + public IReadOnlyList Layers => _layers ?? new List{Icon}; } public enum ConstructionType diff --git a/Resources/Prototypes/Recipes/Construction/utilities.yml b/Resources/Prototypes/Recipes/Construction/utilities.yml index 30e6b46938..29a4e92828 100644 --- a/Resources/Prototypes/Recipes/Construction/utilities.yml +++ b/Resources/Prototypes/Recipes/Construction/utilities.yml @@ -391,6 +391,11 @@ icon: sprite: Structures/Piping/Atmospherics/vent.rsi state: vent_off + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeHalf + - sprite: Structures/Piping/Atmospherics/vent.rsi + state: vent_off conditions: - !type:TileNotBlocked {} @@ -407,6 +412,11 @@ icon: sprite: Structures/Piping/Atmospherics/vent.rsi state: vent_off + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeHalf + - sprite: Structures/Piping/Atmospherics/vent.rsi + state: vent_off conditions: - !type:TileNotBlocked {} @@ -423,6 +433,11 @@ icon: sprite: Structures/Piping/Atmospherics/scrubber.rsi state: scrub_off + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeHalf + - sprite: Structures/Piping/Atmospherics/scrubber.rsi + state: scrub_off conditions: - !type:TileNotBlocked {} @@ -439,6 +454,11 @@ icon: sprite: Structures/Piping/Atmospherics/outletinjector.rsi state: injector + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeHalf + - sprite: Structures/Piping/Atmospherics/outletinjector.rsi + state: injector conditions: - !type:TileNotBlocked {} @@ -456,6 +476,11 @@ icon: sprite: Structures/Piping/Atmospherics/pump.rsi state: pumpPressure + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeStraight + - sprite: Structures/Piping/Atmospherics/pump.rsi + state: pumpPressure conditions: - !type:TileNotBlocked {} @@ -472,6 +497,11 @@ icon: sprite: Structures/Piping/Atmospherics/pump.rsi state: pumpVolume + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeStraight + - sprite: Structures/Piping/Atmospherics/pump.rsi + state: pumpVolume conditions: - !type:TileNotBlocked {} @@ -488,6 +518,11 @@ icon: sprite: Structures/Piping/Atmospherics/pump.rsi state: pumpPassiveGate + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeStraight + - sprite: Structures/Piping/Atmospherics/pump.rsi + state: pumpPassiveGate conditions: - !type:TileNotBlocked {} @@ -504,6 +539,11 @@ icon: sprite: Structures/Piping/Atmospherics/pump.rsi state: pumpManualValve + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeStraight + - sprite: Structures/Piping/Atmospherics/pump.rsi + state: pumpManualValve conditions: - !type:TileNotBlocked {} @@ -520,6 +560,11 @@ icon: sprite: Structures/Piping/Atmospherics/gascanisterport.rsi state: gasCanisterPort + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeHalf + - sprite: Structures/Piping/Atmospherics/gascanisterport.rsi + state: gasCanisterPort conditions: - !type:TileNotBlocked {} @@ -536,6 +581,11 @@ icon: sprite: Structures/Piping/Atmospherics/vent.rsi state: vent_off + layers: + - sprite: Structures/Piping/Atmospherics/pipe.rsi + state: pipeStraight + - sprite: Structures/Piping/Atmospherics/vent.rsi + state: vent_off conditions: - !type:TileNotBlocked {} -- 2.52.0