2023-07-08 14:08:32 +10:00
|
|
|
using System.Numerics;
|
2022-09-06 00:28:23 +10:00
|
|
|
using Robust.Client.Graphics;
|
|
|
|
|
using Robust.Client.ResourceManagement;
|
|
|
|
|
using Robust.Shared.Enums;
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.NPC.HTN;
|
|
|
|
|
|
|
|
|
|
public sealed class HTNOverlay : Overlay
|
|
|
|
|
{
|
2023-09-01 12:30:29 +10:00
|
|
|
private readonly IEntityManager _entManager = default!;
|
|
|
|
|
private readonly Font _font = default!;
|
2022-09-06 00:28:23 +10:00
|
|
|
|
|
|
|
|
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
|
|
|
|
|
2023-10-29 15:29:30 +11:00
|
|
|
public HTNOverlay(IEntityManager entManager, IResourceCache resourceCache)
|
2022-09-06 00:28:23 +10:00
|
|
|
{
|
|
|
|
|
_entManager = entManager;
|
2024-01-31 12:54:38 +00:00
|
|
|
_font = new VectorFont(resourceCache.GetResource<FontResource>("/Fonts/IBMPlexMono/IBMPlexMono-Regular.ttf"), 10);
|
2022-09-06 00:28:23 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2023-09-01 12:30:29 +10:00
|
|
|
var worldPos = xform.WorldPosition;
|
2022-09-06 00:28:23 +10:00
|
|
|
|
|
|
|
|
if (!args.WorldAABB.Contains(worldPos))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
var screenPos = args.ViewportControl.WorldToScreen(worldPos);
|
2023-05-02 04:57:11 +10:00
|
|
|
handle.DrawString(_font, screenPos + new Vector2(0, 10f), comp.DebugText, Color.White);
|
2022-09-06 00:28:23 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|