diff --git a/Content.Client/Backmen/Overlays/Shaders/SaturationScaleOverlay.cs b/Content.Client/Backmen/Overlays/Shaders/SaturationScaleOverlay.cs index 7d983427759..644f998cbbe 100644 --- a/Content.Client/Backmen/Overlays/Shaders/SaturationScaleOverlay.cs +++ b/Content.Client/Backmen/Overlays/Shaders/SaturationScaleOverlay.cs @@ -1,4 +1,7 @@ -using Robust.Client.Graphics; +using System.Numerics; +using Content.Shared._CorvaxNext.Overlays; +using Robust.Client.Graphics; +using Robust.Client.Player; using Robust.Shared.Enums; using Robust.Shared.Prototypes; @@ -7,6 +10,8 @@ namespace Content.Client._CorvaxNext.Overlays.Shaders; public sealed class SaturationScaleOverlay : Overlay { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] IEntityManager _entityManager = default!; public override bool RequestScreenTexture => true; public override OverlaySpace Space => OverlaySpace.WorldSpace; @@ -18,20 +23,29 @@ public SaturationScaleOverlay() { IoCManager.InjectDependencies(this); - _shader = _prototypeManager.Index("SaturationScale").InstanceUnique(); + _shader = _prototypeManager.Index("SaturationScale").Instance().Duplicate(); + } + + protected override bool BeforeDraw(in OverlayDrawArgs args) + { + if (_playerManager.LocalEntity is not { Valid: true } player + || !_entityManager.HasComponent(player)) + return false; + + return base.BeforeDraw(in args); } protected override void Draw(in OverlayDrawArgs args) { - if (ScreenTexture == null) + if (ScreenTexture is null) return; _shader.SetParameter("SCREEN_TEXTURE", ScreenTexture); _shader.SetParameter("saturation", Saturation); var handle = args.WorldHandle; - + handle.SetTransform(Matrix3x2.Identity); handle.UseShader(_shader); handle.DrawRect(args.WorldBounds, Color.White); handle.UseShader(null); diff --git a/Content.Client/Backmen/Overlays/Systems/SaturationScaleSystem.cs b/Content.Client/Backmen/Overlays/Systems/SaturationScaleSystem.cs index 0775190a2e8..37a69e08940 100644 --- a/Content.Client/Backmen/Overlays/Systems/SaturationScaleSystem.cs +++ b/Content.Client/Backmen/Overlays/Systems/SaturationScaleSystem.cs @@ -2,15 +2,14 @@ using Content.Shared._CorvaxNext.Overlays; using Content.Shared.GameTicking; using Robust.Client.Graphics; -using Robust.Client.Player; using Robust.Shared.Player; namespace Content.Client._CorvaxNext.Overlays.Systems; public sealed class SaturationScaleSystem : EntitySystem { - [Dependency] private readonly IPlayerManager _player = default!; [Dependency] private readonly IOverlayManager _overlayMan = default!; + [Dependency] private readonly ISharedPlayerManager _playerMan = default!; private SaturationScaleOverlay _overlay = default!; @@ -48,7 +47,7 @@ private void OnPlayerAttached(EntityUid uid, SaturationScaleOverlayComponent com private void OnShutdown(EntityUid uid, SaturationScaleOverlayComponent component, ComponentShutdown args) { - if (_player.LocalSession?.AttachedEntity != uid) + if (uid != _playerMan.LocalEntity) return; _overlayMan.RemoveOverlay(_overlay); @@ -56,7 +55,7 @@ private void OnShutdown(EntityUid uid, SaturationScaleOverlayComponent component private void OnInit(EntityUid uid, SaturationScaleOverlayComponent component, ComponentInit args) { - if (_player.LocalSession?.AttachedEntity != uid) + if (uid != _playerMan.LocalEntity) return; _overlayMan.AddOverlay(_overlay); diff --git a/Content.Server/Backmen/Mood/MoodSystem.cs b/Content.Server/Backmen/Mood/MoodSystem.cs index 5f0ebde3707..8233c5d6564 100644 --- a/Content.Server/Backmen/Mood/MoodSystem.cs +++ b/Content.Server/Backmen/Mood/MoodSystem.cs @@ -302,7 +302,8 @@ private void RefreshMood(EntityUid uid, MoodComponent component) private void OnInit(EntityUid uid, MoodComponent component, ComponentStartup args) { - if (TryComp(uid, out var mobThresholdsComponent) + if (_config.GetCVar(CCVars.MoodModifiesThresholds) + && TryComp(uid, out var mobThresholdsComponent) && _mobThreshold.TryGetThresholdForState(uid, MobState.Critical, out var critThreshold, mobThresholdsComponent)) component.CritThresholdBeforeModify = critThreshold.Value; @@ -397,7 +398,8 @@ private void RefreshShaders(EntityUid uid, int modifier) private void SetCritThreshold(EntityUid uid, MoodComponent component, int modifier) { - if (!TryComp(uid, out var mobThresholds) + if (!_config.GetCVar(CCVars.MoodModifiesThresholds) + || !TryComp(uid, out var mobThresholds) || !_mobThreshold.TryGetThresholdForState(uid, MobState.Critical, out var key)) return; diff --git a/Content.Shared/_CorvaxNext/NextVars.cs b/Content.Shared/_CorvaxNext/NextVars.cs index 4a5e96c02c1..2effecae306 100644 --- a/Content.Shared/_CorvaxNext/NextVars.cs +++ b/Content.Shared/_CorvaxNext/NextVars.cs @@ -51,4 +51,7 @@ public sealed class NextVars public static readonly CVarDef MoodDecreasesSpeed = CVarDef.Create("mood.decreases_speed", true, CVar.SERVER); + public static readonly CVarDef MoodModifiesThresholds = + CVarDef.Create("mood.modify_thresholds", false, CVar.SERVER); + }