37
Content.Client/White/Overlays/SaturationScaleOverlay.cs
Normal file
37
Content.Client/White/Overlays/SaturationScaleOverlay.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.White.Overlays;
|
||||
|
||||
public sealed class SaturationScaleOverlay : Overlay
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public override bool RequestScreenTexture => true;
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
private readonly ShaderInstance _shader;
|
||||
private const float Saturation = 0.5f;
|
||||
|
||||
public SaturationScaleOverlay()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_shader = _prototypeManager.Index<ShaderPrototype>("SaturationScale").InstanceUnique();
|
||||
}
|
||||
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
{
|
||||
if (ScreenTexture == null)
|
||||
return;
|
||||
|
||||
_shader.SetParameter("SCREEN_TEXTURE", ScreenTexture);
|
||||
_shader.SetParameter("saturation", Saturation);
|
||||
|
||||
var handle = args.WorldHandle;
|
||||
|
||||
handle.UseShader(_shader);
|
||||
handle.DrawRect(args.WorldBounds, Color.White);
|
||||
handle.UseShader(null);
|
||||
}
|
||||
}
|
||||
61
Content.Client/White/Overlays/SaturationScaleSystem.cs
Normal file
61
Content.Client/White/Overlays/SaturationScaleSystem.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.White.Overlays;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Client.White.Overlays;
|
||||
|
||||
public sealed class SaturationScaleSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _player = default!;
|
||||
[Dependency] private readonly IOverlayManager _overlayMan = default!;
|
||||
[Dependency] private readonly ILightManager _lightManager = default!;
|
||||
|
||||
private SaturationScaleOverlay _overlay = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SaturationScaleComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<SaturationScaleComponent, ComponentShutdown>(OnShutdown);
|
||||
|
||||
SubscribeLocalEvent<SaturationScaleComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
||||
SubscribeLocalEvent<SaturationScaleComponent, PlayerDetachedEvent>(OnPlayerDetached);
|
||||
|
||||
SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup);
|
||||
|
||||
_overlay = new();
|
||||
}
|
||||
|
||||
private void RoundRestartCleanup(RoundRestartCleanupEvent ev)
|
||||
{
|
||||
_overlayMan.RemoveOverlay(_overlay);
|
||||
}
|
||||
|
||||
private void OnPlayerDetached(EntityUid uid, SaturationScaleComponent component, PlayerDetachedEvent args)
|
||||
{
|
||||
_overlayMan.RemoveOverlay(_overlay);
|
||||
}
|
||||
|
||||
private void OnPlayerAttached(EntityUid uid, SaturationScaleComponent component, PlayerAttachedEvent args)
|
||||
{
|
||||
_overlayMan.AddOverlay(_overlay);
|
||||
}
|
||||
|
||||
private void OnShutdown(EntityUid uid, SaturationScaleComponent component, ComponentShutdown args)
|
||||
{
|
||||
if (_player.LocalPlayer?.ControlledEntity == uid)
|
||||
{
|
||||
_overlayMan.RemoveOverlay(_overlay);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, SaturationScaleComponent component, ComponentInit args)
|
||||
{
|
||||
if (_player.LocalPlayer?.ControlledEntity == uid)
|
||||
_overlayMan.AddOverlay(_overlay);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user