mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
using Content.Shared.Shaders;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Player;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Shaders.Systems;
|
|
|
|
public sealed partial class NoirVisionOverlay : Overlay
|
|
{
|
|
[Dependency] private IEntityManager _entityManager = default!;
|
|
[Dependency] private IPlayerManager _playerManager = default!;
|
|
[Dependency] private IPrototypeManager _prototypeManager = default!;
|
|
|
|
private static readonly ProtoId<ShaderPrototype> Noir = "Noir";
|
|
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
|
public override bool RequestScreenTexture => true;
|
|
private readonly ShaderInstance _redHighlightShader;
|
|
|
|
public float RedThreshold = 0f;
|
|
public float RedSaturation = 1.0f;
|
|
|
|
public NoirVisionOverlay()
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
_redHighlightShader = _prototypeManager.Index(Noir).InstanceUnique();
|
|
}
|
|
|
|
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
|
{
|
|
if (!_entityManager.TryGetComponent(_playerManager.LocalEntity, out EyeComponent? eyeComp))
|
|
return false;
|
|
|
|
if (args.Viewport.Eye != eyeComp.Eye)
|
|
return false;
|
|
|
|
if (_entityManager.TryGetComponent<NoirVisionComponent>(_playerManager.LocalEntity, out var noirVision))
|
|
{
|
|
RedThreshold = noirVision.RedThreshold;
|
|
RedSaturation = noirVision.RedSaturation;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
protected override void Draw(in OverlayDrawArgs args)
|
|
{
|
|
if (ScreenTexture == null)
|
|
return;
|
|
|
|
var handle = args.WorldHandle;
|
|
|
|
_redHighlightShader.SetParameter("SCREEN_TEXTURE", ScreenTexture);
|
|
_redHighlightShader.SetParameter("RedThreshold", RedThreshold);
|
|
_redHighlightShader.SetParameter("RedSaturation", RedSaturation);
|
|
handle.UseShader(_redHighlightShader);
|
|
handle.DrawRect(args.WorldBounds, Color.White);
|
|
handle.UseShader(null);
|
|
}
|
|
}
|