security HUD now shows a job icon on entities with a body (#18054)

This commit is contained in:
PrPleGoo
2023-08-01 23:17:03 +02:00
committed by GitHub
parent 9d4c1a254a
commit e083b33aae
11 changed files with 256 additions and 13 deletions

View File

@@ -1,8 +1,9 @@
using System.Numerics;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using System.Numerics;
namespace Content.Client.StatusIcon;
@@ -41,10 +42,6 @@ public sealed class StatusIconOverlay : Overlay
if (xform.MapID != args.MapId)
continue;
var icons = _statusIcon.GetStatusIcons(uid, meta);
if (icons.Count == 0)
continue;
var bounds = comp.Bounds ?? sprite.Bounds;
var worldPos = _transform.GetWorldPosition(xform, xformQuery);
@@ -52,12 +49,17 @@ public sealed class StatusIconOverlay : Overlay
if (!bounds.Translated(worldPos).Intersects(args.WorldAABB))
continue;
var icons = _statusIcon.GetStatusIcons(uid, meta);
if (icons.Count == 0)
continue;
var worldMatrix = Matrix3.CreateTranslation(worldPos);
Matrix3.Multiply(scaleMatrix, worldMatrix, out var scaledWorld);
Matrix3.Multiply(rotationMatrix, scaledWorld, out var matty);
handle.SetTransform(matty);
var count = 0;
var countL = 0;
var countR = 0;
var accOffsetL = 0;
var accOffsetR = 0;
icons.Sort();
@@ -71,13 +73,16 @@ public sealed class StatusIconOverlay : Overlay
// the icons are ordered left to right, top to bottom.
// extra icons that don't fit are just cut off.
if (count % 2 == 0)
if (proto.LocationPreference == StatusIconLocationPreference.Left ||
proto.LocationPreference == StatusIconLocationPreference.None && countL <= countR)
{
if (accOffsetL + texture.Height > sprite.Bounds.Height * EyeManager.PixelsPerMeter)
break;
accOffsetL += texture.Height;
yOffset = (bounds.Height + sprite.Offset.Y) / 2f - (float) accOffsetL / EyeManager.PixelsPerMeter;
xOffset = -(bounds.Width + sprite.Offset.X) / 2f;
countL++;
}
else
{
@@ -86,8 +91,9 @@ public sealed class StatusIconOverlay : Overlay
accOffsetR += texture.Height;
yOffset = (bounds.Height + sprite.Offset.Y) / 2f - (float) accOffsetR / EyeManager.PixelsPerMeter;
xOffset = (bounds.Width + sprite.Offset.X) / 2f - (float) texture.Width / EyeManager.PixelsPerMeter;
countR++;
}
count++;
var position = new Vector2(xOffset, yOffset);
handle.DrawTexture(texture, position);