]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add layers field to construction prototype (#14222)
author08A <git@08a.re>
Sat, 4 Mar 2023 20:31:46 +0000 (21:31 +0100)
committerGitHub <noreply@github.com>
Sat, 4 Mar 2023 20:31:46 +0000 (07:31 +1100)
Content.Client/Construction/ConstructionPlacementHijack.cs
Content.Client/Construction/ConstructionSystem.cs
Content.Shared/Construction/Prototypes/ConstructionPrototype.cs
Resources/Prototypes/Recipes/Construction/utilities.yml

index f6a7f4c62401f10f232ff7f1d619796c1eb9a903..e2e6ab66924705e5e5a6f6231041b294bb159748 100644 (file)
@@ -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<IDirectionalTextureProvider> {frame};
-            }
+            manager.CurrentTextures = _prototype?.Layers.Select(sprite => sprite.DirFrame0()).ToList();
         }
     }
 }
index e8138824735c7226b975bb24dd2f775317832812..c16d533a2ec50e4d2c6b9dc46d2f5177380b1687 100644 (file)
@@ -179,10 +179,14 @@ namespace Content.Client.Construction
             _ghosts.Add(comp.GhostId, comp);
             var sprite = EntityManager.GetComponent<SpriteComponent>(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<WallMountComponent>(ghost).Arc = new(Math.Tau);
index cb4bf5814d85e37bc7b5e8e8802a809385943c6f..84b0b8591a44abd4dad2932101b138a8216838ce 100644 (file)
@@ -46,6 +46,12 @@ namespace Content.Shared.Construction.Prototypes
         [DataField("icon")]
         public SpriteSpecifier Icon { get; } = SpriteSpecifier.Invalid;
 
+        /// <summary>
+        ///     Texture paths used for the construction ghost.
+        /// </summary>
+        [DataField("layers")]
+        private List<SpriteSpecifier>? _layers;
+
         /// <summary>
         ///     If you can start building or complete steps on impassable terrain.
         /// </summary>
@@ -70,6 +76,7 @@ namespace Content.Shared.Construction.Prototypes
         public bool CanRotate { get; } = true;
 
         public IReadOnlyList<IConstructionCondition> Conditions => _conditions;
+        public IReadOnlyList<SpriteSpecifier> Layers => _layers ?? new List<SpriteSpecifier>{Icon};
     }
 
     public enum ConstructionType
index 30e6b46938917d9bb4759be1291b575b10a9a7ce..29a4e92828fbf39934c706eca070fa4b1feb50dc 100644 (file)
   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 {}
 
   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 {}
 
   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 {}
 
   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 {}
 
   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 {}
 
   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 {}
 
   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 {}
 
   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 {}
 
   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 {}
 
   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 {}