[Fix] Mood system fix (#439)

* mood back

* fix ready
This commit is contained in:
HitPanda
2023-09-25 01:44:44 +03:00
committed by Aviu00
parent c58225fc98
commit 2cd1656188
47 changed files with 1221 additions and 7 deletions

View 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);
}
}

View 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);
}
}