From: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Date: Tue, 16 Dec 2025 19:19:37 +0000 (+0100)
Subject: wallmount debug overlay (#38495)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=19126949c37ae7328c6f7c091848cdaebad3809d;p=space-station-14.git
wallmount debug overlay (#38495)
* wallmount debug overlay
* make circles a little smoother
* add permissions
* Update Resources/Locale/en-US/commands/show-wallmounts-command.ftl
Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com>
* fix
---------
Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com>
Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
---
diff --git a/Content.Client/Commands/ShowWallmountsCommand.cs b/Content.Client/Commands/ShowWallmountsCommand.cs
new file mode 100644
index 0000000000..d44c13911b
--- /dev/null
+++ b/Content.Client/Commands/ShowWallmountsCommand.cs
@@ -0,0 +1,24 @@
+using Content.Client.Wall;
+using Robust.Client.Graphics;
+using Robust.Shared.Console;
+
+namespace Content.Client.Commands;
+
+///
+/// Shows the area in which entities with can be interacted from.
+///
+public sealed class ShowWallmountsCommand : LocalizedCommands
+{
+ [Dependency] private readonly IOverlayManager _overlay = default!;
+
+ public override string Command => "showwallmounts";
+
+ public override void Execute(IConsoleShell shell, string argStr, string[] args)
+ {
+ var existing = _overlay.RemoveOverlay();
+ if (!existing)
+ _overlay.AddOverlay(new WallmountDebugOverlay());
+
+ shell.WriteLine(Loc.GetString("cmd-showwallmounts-status", ("status", !existing)));
+ }
+}
diff --git a/Content.Client/Wall/WallmountDebugOverlay.cs b/Content.Client/Wall/WallmountDebugOverlay.cs
new file mode 100644
index 0000000000..02fd9ebeec
--- /dev/null
+++ b/Content.Client/Wall/WallmountDebugOverlay.cs
@@ -0,0 +1,58 @@
+using Content.Shared.Interaction;
+using Content.Shared.Wall;
+using Robust.Client.Graphics;
+using Robust.Shared.Enums;
+using System.Numerics;
+
+namespace Content.Client.Wall;
+
+///
+/// Shows the area in which entities with can be interacted from.
+///
+public sealed class WallmountDebugOverlay : Overlay
+{
+ [Dependency] private readonly IEntityManager _entManager = default!;
+ private readonly SharedTransformSystem _transform;
+ private readonly EntityLookupSystem _lookup;
+ private readonly HashSet> _intersecting = [];
+
+ public override OverlaySpace Space => OverlaySpace.WorldSpace;
+
+ public WallmountDebugOverlay()
+ {
+ IoCManager.InjectDependencies(this);
+
+ _transform = _entManager.System();
+ _lookup = _entManager.System();
+ }
+
+ protected override void Draw(in OverlayDrawArgs args)
+ {
+ _intersecting.Clear();
+ _lookup.GetEntitiesIntersecting(args.MapId, args.WorldBounds, _intersecting);
+ foreach (var ent in _intersecting)
+ {
+ var (worldPos, worldRot) = _transform.GetWorldPositionRotation(ent.Owner);
+ DrawArc(args.WorldHandle, worldPos, SharedInteractionSystem.InteractionRange, worldRot + ent.Comp.Direction, ent.Comp.Arc);
+ }
+ }
+
+ private static void DrawArc(DrawingHandleWorld handle, Vector2 position, float radius, Angle rot, Angle arc)
+ {
+ // 32 segments for a full circle, but 2 at least
+ var segments = Math.Max((int)(arc.Theta / Math.Tau * 32), 2);
+ var step = arc.Theta / (segments - 1);
+ var verts = new Vector2[segments + 1];
+
+ verts[0] = position;
+ for (var i = 0; i < segments; i++)
+ {
+ var angle = (float)(-arc.Theta / 2 + i * step - rot.Theta + Math.PI);
+ var pos = new Vector2(MathF.Sin(angle), MathF.Cos(angle));
+
+ verts[i + 1] = position + pos * radius;
+ }
+
+ handle.DrawPrimitives(DrawPrimitiveTopology.TriangleFan, verts, Color.Green.WithAlpha(0.5f));
+ }
+}
diff --git a/Resources/Locale/en-US/commands/show-wallmounts-command.ftl b/Resources/Locale/en-US/commands/show-wallmounts-command.ftl
new file mode 100644
index 0000000000..062a51d964
--- /dev/null
+++ b/Resources/Locale/en-US/commands/show-wallmounts-command.ftl
@@ -0,0 +1,3 @@
+cmd-showwallmounts-desc = Toggles showing wallmount interaction areas.
+cmd-showwallmounts-help = Usage: {$command}
+cmd-showwallmounts-status = Set wallmount debug overlay to {$status}.
diff --git a/Resources/clientCommandPerms.yml b/Resources/clientCommandPerms.yml
index a177bc5fe1..9b086f6fdf 100644
--- a/Resources/clientCommandPerms.yml
+++ b/Resources/clientCommandPerms.yml
@@ -73,6 +73,7 @@
- localdelete
- fullstatereset
- dumpentities
+ - showwallmounts
- showaccessreaders
- quickinspect
@@ -84,6 +85,7 @@
- showsubfloorforever
- toggleautosave
- toggledecals
+ - showwallmounts
- showaccessreaders
- Flags: QUERY