]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
t-ray reveal for entities and draw depth fix (#33012)
authorqwerltaz <msmarcinpl@gmail.com>
Thu, 27 Feb 2025 10:46:09 +0000 (10:46 +0000)
committerGitHub <noreply@github.com>
Thu, 27 Feb 2025 10:46:09 +0000 (11:46 +0100)
* t-rays show above catwalk

* a

* RevealSubfloorComponent

* revealSubfloorOnScan, add it to catwalk

* TrayScanReveal sys and comp

* Rr

* handle anchoring

* use tile indices for vector2i

* fix IsUnderRevealingEntity reset on pvs pop in reanchor

* fix exception on TrayScanRevealComponent remove

* fix IsUnderRevealingEntity not updating on pvs enter

* update to ent

* make subfloor retain respect for their relative draw depth

* fix carpets not revealing subfloor on plating

* chapel carpet

* ??

* draw depth gap for subfloor entities.

* revert alpha change

* remove abs from draw depth difference

* move TrayScanReveal to client

* delete old refactor

* let's show them above puddles too

* Remove superfluous component classes

---------

Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
Content.Client/SubFloor/SubFloorHideSystem.cs
Content.Client/SubFloor/TrayScanRevealSystem.cs [new file with mode: 0644]
Content.Client/SubFloor/TrayScannerSystem.cs
Content.Shared/DrawDepth/DrawDepth.cs
Content.Shared/SubFloor/TrayScanRevealComponent.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Structures/Furniture/carpets.yml
Resources/Prototypes/Entities/Structures/catwalk.yml

index 64d3afc640ea590184ef694ccf8f2070cf4c3f1e..5e5f2993b43d74c8a908a8601e5c84df401382d8 100644 (file)
@@ -67,8 +67,11 @@ public sealed class SubFloorHideSystem : SharedSubFloorHideSystem
         // allows a t-ray to show wires/pipes above carpets/puddles
         if (scannerRevealed)
         {
-            component.OriginalDrawDepth ??= args.Sprite.DrawDepth;
-            args.Sprite.DrawDepth = (int) Shared.DrawDepth.DrawDepth.FloorObjects + 1;
+            if (component.OriginalDrawDepth is not null)
+                return;
+            component.OriginalDrawDepth = args.Sprite.DrawDepth;
+            var drawDepthDifference = Shared.DrawDepth.DrawDepth.ThickPipe - Shared.DrawDepth.DrawDepth.Puddles;
+            args.Sprite.DrawDepth -= drawDepthDifference - 1;
         }
         else if (component.OriginalDrawDepth.HasValue)
         {
diff --git a/Content.Client/SubFloor/TrayScanRevealSystem.cs b/Content.Client/SubFloor/TrayScanRevealSystem.cs
new file mode 100644 (file)
index 0000000..ca3e91a
--- /dev/null
@@ -0,0 +1,29 @@
+using System.Linq;
+using Content.Shared.SubFloor;
+using Robust.Shared.Map.Components;
+
+namespace Content.Client.SubFloor;
+
+public sealed class TrayScanRevealSystem : EntitySystem
+{
+    [Dependency] private readonly SharedTransformSystem _transform = default!;
+    [Dependency] private readonly SharedMapSystem _map = default!;
+
+    public bool IsUnderRevealingEntity(EntityUid uid)
+    {
+        var gridUid = _transform.GetGrid(uid);
+        if (gridUid is null)
+            return false;
+
+        var gridComp = Comp<MapGridComponent>(gridUid.Value);
+        var position = _transform.GetGridOrMapTilePosition(uid);
+
+        return HasTrayScanReveal(((EntityUid)gridUid, gridComp), position);
+    }
+
+    private bool HasTrayScanReveal(Entity<MapGridComponent> ent, Vector2i position)
+    {
+        var anchoredEnum = _map.GetAnchoredEntities(ent, position);
+        return anchoredEnum.Any(HasComp<TrayScanRevealComponent>);
+    }
+}
index 95bce03c0f9cf5563be3f4593f4e5079e0f3e853..f65c7840256f5caf42882f0a9a3cadc188f6b0cb 100644 (file)
@@ -19,6 +19,7 @@ public sealed class TrayScannerSystem : SharedTrayScannerSystem
     [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
     [Dependency] private readonly SharedHandsSystem _hands = default!;
     [Dependency] private readonly SharedTransformSystem _transform = default!;
+    [Dependency] private readonly TrayScanRevealSystem _trayScanReveal = default!;
 
     private const string TRayAnimationKey = "trays";
     private const double AnimationLength = 0.3;
@@ -82,7 +83,7 @@ public sealed class TrayScannerSystem : SharedTrayScannerSystem
 
             foreach (var (uid, comp) in inRange)
             {
-                if (comp.IsUnderCover)
+                if (comp.IsUnderCover || _trayScanReveal.IsUnderRevealingEntity(uid))
                     EnsureComp<TrayRevealedComponent>(uid);
             }
         }
index 4a93b5f0eaf37a467b937f86baa686fca3070835..2c1a130da4c48e5a4ecccbf3a0a18f9fa143c204 100644 (file)
@@ -9,38 +9,39 @@ namespace Content.Shared.DrawDepth
         /// <summary>
         ///     This is for sub-floors, the floors you see after prying off a tile.
         /// </summary>
-        LowFloors = DrawDepthTag.Default - 14,
+        LowFloors = DrawDepthTag.Default - 18,
 
         // various entity types that require different
         // draw depths, as to avoid hiding
         #region SubfloorEntities
-        ThickPipe = DrawDepthTag.Default - 13,
-        ThickWire = DrawDepthTag.Default - 12,
-        ThinPipe = DrawDepthTag.Default - 11,
-        ThinWire = DrawDepthTag.Default - 10,
+        ThickPipe = DrawDepthTag.Default - 17,
+        ThickWire = DrawDepthTag.Default - 16,
+        ThinPipe = DrawDepthTag.Default - 15,
+        ThinWire = DrawDepthTag.Default - 14,
         #endregion
 
         /// <summary>
         ///     Things that are beneath regular floors.
         /// </summary>
-        BelowFloor = DrawDepthTag.Default - 9,
+        BelowFloor = DrawDepthTag.Default - 13,
 
         /// <summary>
         ///     Used for entities like carpets.
         /// </summary>
-        FloorTiles = DrawDepthTag.Default - 8,
+        FloorTiles = DrawDepthTag.Default - 12,
 
         /// <summary>
         ///     Things that are actually right on the floor, like ice crust or atmos devices. This does not mean objects like
         ///     tables, even though they are technically "on the floor".
         /// </summary>
-        FloorObjects = DrawDepthTag.Default - 7,
+        FloorObjects = DrawDepthTag.Default - 11,
 
         /// <summary>
         //     Discrete drawdepth to avoid z-fighting with other FloorObjects but also above floor entities.
         /// </summary>
-        Puddles = DrawDepthTag.Default - 6,
+        Puddles = DrawDepthTag.Default - 10,
 
+        // There's a gap for subfloor entities to retain relative draw depth when revealed by a t-ray scanner.
         /// <summary>
         //     Objects that are on the floor, but should render above puddles. This includes kudzu, holopads, telepads and levers.
         /// </summary>
diff --git a/Content.Shared/SubFloor/TrayScanRevealComponent.cs b/Content.Shared/SubFloor/TrayScanRevealComponent.cs
new file mode 100644 (file)
index 0000000..ebe680c
--- /dev/null
@@ -0,0 +1,10 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.SubFloor;
+
+/// <summary>
+/// For tile-like entities, such as catwalk and carpets, to reveal subfloor entities when on the same tile and when
+/// using a t-ray scanner.
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class TrayScanRevealComponent : Component;
index 77a0b2df1d97c6345e9d0576ddd3d9381e9ea9cc..d82ba95d76389846e745451ee9dc70c8ac5657e3 100644 (file)
@@ -36,6 +36,7 @@
     spawned:
     - id: MaterialCloth1
       amount: 1
+  - type: TrayScanReveal
 
 - type: entity
   id: Carpet
         behaviors:
           - !type:DoActsBehavior
             acts: [ "Destruction" ]
+  - type: TrayScanReveal
index ed355f0ec8b7a6339c08106bdbf8ac0935b2724a..0a44c338a4d5ae7f9ee365f3f1804b66d76c79bb 100644 (file)
@@ -51,6 +51,7 @@
             max: 1
       - !type:DoActsBehavior
         acts: [ "Destruction" ]
+  - type: TrayScanReveal
   - type: RCDDeconstructable
     cost: 2
     delay: 2