Files
tbd-station-14/Content.Client/NPC/HTN/HTNOverlay.cs
Plykiya a87efd7d01 Replace xform.WorldPosition with xformSystem method for Setting/Getting (#30029)
* GET WORLD POSITON, ROTATION

* Missing parentheses

* ui system depndency

* the issue

* Unused

* Let the function do the transform

---------

Co-authored-by: plykiya <plykiya@protonmail.com>
2024-08-06 21:02:01 +10:00

45 lines
1.4 KiB
C#

using System.Numerics;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Enums;
namespace Content.Client.NPC.HTN;
public sealed class HTNOverlay : Overlay
{
private readonly IEntityManager _entManager = default!;
private readonly Font _font = default!;
private readonly SharedTransformSystem _transformSystem;
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
public HTNOverlay(IEntityManager entManager, IResourceCache resourceCache)
{
_entManager = entManager;
_font = new VectorFont(resourceCache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
_transformSystem = _entManager.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
{
if (args.ViewportControl == null)
return;
var handle = args.ScreenHandle;
foreach (var (comp, xform) in _entManager.EntityQuery<HTNComponent, TransformComponent>(true))
{
if (string.IsNullOrEmpty(comp.DebugText) || xform.MapID != args.MapId)
continue;
var worldPos = _transformSystem.GetWorldPosition(xform);
if (!args.WorldAABB.Contains(worldPos))
continue;
var screenPos = args.ViewportControl.WorldToScreen(worldPos);
handle.DrawString(_font, screenPos + new Vector2(0, 10f), comp.DebugText, Color.White);
}
}
}