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)
This commit is contained in:
20kdc
2021-01-24 08:17:45 +00:00
committed by GitHub
parent 329d599107
commit e53ae365a3
21 changed files with 65 additions and 659 deletions

View File

@@ -1,8 +1,10 @@
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;
@@ -13,18 +15,43 @@ namespace Content.Client.Graphics.Overlays
{
[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(SharedOverlayID.GradientCircleMaskOverlay))
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();