Files
OldThink/Content.Client/_White/Cult/CultHudOverlay.cs
Cinka f02cc9cb87
Some checks failed
Build & Test Map Renderer / build (ubuntu-latest) (push) Has been cancelled
Build & Test Debug / build (ubuntu-latest) (push) Has been cancelled
Check Merge Conflicts / Label (push) Has been cancelled
Test Packaging / Test Packaging (push) Has been cancelled
RGA schema validator / YAML RGA schema validator (push) Has been cancelled
Map file schema validator / YAML map schema validator (push) Has been cancelled
YAML Linter / YAML Linter (push) Has been cancelled
Build & Test Map Renderer / Build & Test Debug (push) Has been cancelled
Build & Test Debug / Build & Test Debug (push) Has been cancelled
Benchmarks / Run Benchmarks (push) Has been cancelled
Update Contrib and Patreons in credits / get_credits (push) Has been cancelled
Build & Publish Docfx / docfx (push) Has been cancelled
- fix: engine update fix
2026-02-01 14:47:44 +03:00

86 lines
3.1 KiB
C#

using System.Numerics;
using Content.Shared._White.Cult;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.Utility;
using CultistComponent = Content.Shared._White.Cult.Components.CultistComponent;
namespace Content.Client._White.Cult;
public sealed class CultHudOverlay : Overlay
{
private readonly IEntityManager _entityManager;
private readonly SharedTransformSystem _transformSystem;
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
protected override void Draw(in OverlayDrawArgs args)
{
var handle = args.WorldHandle;
var rotation = args.Viewport.Eye?.Rotation ?? Angle.Zero;
var spriteQuery = _entityManager.GetEntityQuery<SpriteComponent>();
var xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
const float scale = 1f;
var scaleMatrix = Matrix3.CreateScale(new Vector2(scale, scale));
var rotationMatrix = Matrix3Helpers.CreateRotation(-rotation);
foreach (var cultist in _entityManager.EntityQuery<CultistComponent>(true))
{
if (!xformQuery.TryGetComponent(cultist.Owner, out var xform) ||
xform.MapID != args.MapId)
{
continue;
}
var worldPosition = _transformSystem.GetWorldPosition(xform);
var worldMatrix = Matrix3.CreateTranslation(worldPosition);
ContentMathHelper.Multiply(scaleMatrix, worldMatrix, out var scaledWorld);
ContentMathHelper.Multiply(rotationMatrix, scaledWorld, out var matty);
handle.SetTransform(matty);
var cultistIcon = new SpriteSpecifier.Rsi(new ResPath("/Textures/White/Cult/cult_hud.rsi"), "cult");
var iconTexture = _entityManager.EntitySysManager.GetEntitySystem<SpriteSystem>().Frame0(cultistIcon);
float yOffset;
float xOffset;
if (spriteQuery.TryGetComponent(cultist.Owner, out var sprite))
{
yOffset = sprite.Bounds.Height - 10f; //sprite.Bounds.Height + 7f;
xOffset = sprite.Bounds.Width - 40f; //sprite.Bounds.Width + 7f;
}
else
{
yOffset = 1f;
xOffset = 1f;
}
// Position above the entity (we've already applied the matrix transform to the entity itself)
// Offset by the texture size for every do_after we have.
var position = new Vector2(xOffset / EyeManager.PixelsPerMeter, yOffset / EyeManager.PixelsPerMeter);
// Draw the underlying bar texture
if (sprite != null && !sprite.ContainerOccluded)
{
handle.DrawTexture(iconTexture, position);
}
}
handle.UseShader(null);
handle.SetTransform(Matrix3.Identity);
}
public CultHudOverlay(IEntityManager entityManager)
{
_entityManager = entityManager;
_transformSystem = _entityManager.EntitySysManager.GetEntitySystem<SharedTransformSystem>();
}
}