53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using System.Numerics;
|
|
using Content.Shared.DeltaV.Pain;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Player;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.DeltaV.Overlays;
|
|
|
|
public sealed partial class PainOverlay : Overlay
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
[Dependency] private readonly IPlayerManager _player = default!;
|
|
[Dependency] private readonly IEntityManager _entity = default!;
|
|
|
|
public override bool RequestScreenTexture => true;
|
|
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
|
private readonly ShaderInstance _painShader;
|
|
private readonly ProtoId<ShaderPrototype> _shaderProto = "ChromaticAberration";
|
|
|
|
public PainOverlay()
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
_painShader = _prototype.Index(_shaderProto).Instance().Duplicate();
|
|
}
|
|
|
|
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
|
{
|
|
if (_player.LocalEntity is not { Valid: true } player
|
|
|| !_entity.HasComponent<PainComponent>(player))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return base.BeforeDraw(in args);
|
|
}
|
|
|
|
protected override void Draw(in OverlayDrawArgs args)
|
|
{
|
|
if (ScreenTexture is null)
|
|
return;
|
|
|
|
_painShader.SetParameter("SCREEN_TEXTURE", ScreenTexture);
|
|
|
|
var worldHandle = args.WorldHandle;
|
|
var viewport = args.WorldBounds;
|
|
worldHandle.SetTransform(Matrix3x2.Identity);
|
|
worldHandle.UseShader(_painShader);
|
|
worldHandle.DrawRect(viewport, Color.White);
|
|
worldHandle.UseShader(null);
|
|
}
|
|
}
|