From: qwerltaz Date: Thu, 27 Feb 2025 10:46:09 +0000 (+0000) Subject: t-ray reveal for entities and draw depth fix (#33012) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=7b0b4013125a5a1101d69c958f97b9d315968702;p=space-station-14.git t-ray reveal for entities and draw depth fix (#33012) * 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 --- diff --git a/Content.Client/SubFloor/SubFloorHideSystem.cs b/Content.Client/SubFloor/SubFloorHideSystem.cs index 64d3afc640..5e5f2993b4 100644 --- a/Content.Client/SubFloor/SubFloorHideSystem.cs +++ b/Content.Client/SubFloor/SubFloorHideSystem.cs @@ -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 index 0000000000..ca3e91a7dc --- /dev/null +++ b/Content.Client/SubFloor/TrayScanRevealSystem.cs @@ -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(gridUid.Value); + var position = _transform.GetGridOrMapTilePosition(uid); + + return HasTrayScanReveal(((EntityUid)gridUid, gridComp), position); + } + + private bool HasTrayScanReveal(Entity ent, Vector2i position) + { + var anchoredEnum = _map.GetAnchoredEntities(ent, position); + return anchoredEnum.Any(HasComp); + } +} diff --git a/Content.Client/SubFloor/TrayScannerSystem.cs b/Content.Client/SubFloor/TrayScannerSystem.cs index 95bce03c0f..f65c784025 100644 --- a/Content.Client/SubFloor/TrayScannerSystem.cs +++ b/Content.Client/SubFloor/TrayScannerSystem.cs @@ -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(uid); } } diff --git a/Content.Shared/DrawDepth/DrawDepth.cs b/Content.Shared/DrawDepth/DrawDepth.cs index 4a93b5f0ea..2c1a130da4 100644 --- a/Content.Shared/DrawDepth/DrawDepth.cs +++ b/Content.Shared/DrawDepth/DrawDepth.cs @@ -9,38 +9,39 @@ namespace Content.Shared.DrawDepth /// /// This is for sub-floors, the floors you see after prying off a tile. /// - 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 /// /// Things that are beneath regular floors. /// - BelowFloor = DrawDepthTag.Default - 9, + BelowFloor = DrawDepthTag.Default - 13, /// /// Used for entities like carpets. /// - FloorTiles = DrawDepthTag.Default - 8, + FloorTiles = DrawDepthTag.Default - 12, /// /// 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". /// - FloorObjects = DrawDepthTag.Default - 7, + FloorObjects = DrawDepthTag.Default - 11, /// // Discrete drawdepth to avoid z-fighting with other FloorObjects but also above floor entities. /// - 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. /// // Objects that are on the floor, but should render above puddles. This includes kudzu, holopads, telepads and levers. /// diff --git a/Content.Shared/SubFloor/TrayScanRevealComponent.cs b/Content.Shared/SubFloor/TrayScanRevealComponent.cs new file mode 100644 index 0000000000..ebe680c637 --- /dev/null +++ b/Content.Shared/SubFloor/TrayScanRevealComponent.cs @@ -0,0 +1,10 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.SubFloor; + +/// +/// 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. +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class TrayScanRevealComponent : Component; diff --git a/Resources/Prototypes/Entities/Structures/Furniture/carpets.yml b/Resources/Prototypes/Entities/Structures/Furniture/carpets.yml index 77a0b2df1d..d82ba95d76 100644 --- a/Resources/Prototypes/Entities/Structures/Furniture/carpets.yml +++ b/Resources/Prototypes/Entities/Structures/Furniture/carpets.yml @@ -36,6 +36,7 @@ spawned: - id: MaterialCloth1 amount: 1 + - type: TrayScanReveal - type: entity id: Carpet @@ -364,3 +365,4 @@ behaviors: - !type:DoActsBehavior acts: [ "Destruction" ] + - type: TrayScanReveal diff --git a/Resources/Prototypes/Entities/Structures/catwalk.yml b/Resources/Prototypes/Entities/Structures/catwalk.yml index ed355f0ec8..0a44c338a4 100644 --- a/Resources/Prototypes/Entities/Structures/catwalk.yml +++ b/Resources/Prototypes/Entities/Structures/catwalk.yml @@ -51,6 +51,7 @@ max: 1 - !type:DoActsBehavior acts: [ "Destruction" ] + - type: TrayScanReveal - type: RCDDeconstructable cost: 2 delay: 2