Files
tbd-station-14/Content.Client/Graphics/Overlays/GradientCircleMask.cs
20kdc e53ae365a3 Get rid of the OverlayEffectsComponent stuff (#3010)
* Get rid of the OverlayEffectsComponent stuff because it just ended up creating workarounds for it's bugs, without removing any functionality

* Flashes and Flashbangs use the same code now (the Flashable path because it's better)
2021-01-24 19:17:45 +11:00

62 lines
2.1 KiB
C#

using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Mobs.State;
using Robust.Client.Graphics.Drawing;
using Robust.Client.Graphics.Overlays;
using Robust.Client.Graphics.Shaders;
using Robust.Client.Interfaces.Graphics.ClientEye;
using Robust.Client.Player;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
namespace Content.Client.Graphics.Overlays
{
public class GradientCircleMaskOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _shader;
public GradientCircleMaskOverlay() : base(nameof(GradientCircleMaskOverlay))
{
IoCManager.InjectDependencies(this);
_shader = _prototypeManager.Index<ShaderPrototype>("GradientCircleMask").Instance();
}
public static bool LocalPlayerHasState(IPlayerManager pm, bool critical, bool dead) {
var playerEntity = pm.LocalPlayer?.ControlledEntity;
if (playerEntity == null)
{
return false;
}
if (playerEntity.TryGetComponent<IMobStateComponent>(out var mobState))
{
if (critical)
if (mobState.IsCritical())
return true;
if (dead)
if (mobState.IsDead())
return true;
}
return false;
}
protected override void Draw(DrawingHandleBase handle, OverlaySpace currentSpace)
{
if (!LocalPlayerHasState(_playerManager, true, false))
return;
handle.UseShader(_shader);
var worldHandle = (DrawingHandleWorld)handle;
var viewport = _eyeManager.GetWorldViewport();
worldHandle.DrawRect(viewport, Color.White);
}
}
}