From 4d381ac923a0445528167571ceefd9303ad70b6b Mon Sep 17 00:00:00 2001 From: nukkuminen <90336027+oldschoolotaku@users.noreply.github.com> Date: Fri, 12 Sep 2025 17:25:53 +0300 Subject: [PATCH] Make the magic vision effect better (#1766) * Make the magic vision effect better * whoops * Lowered the intensity of the effect Added support to remove the effect via settings --- .../MagicVision/CP14MagicVisionOverlay.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Content.Client/_CP14/MagicVision/CP14MagicVisionOverlay.cs b/Content.Client/_CP14/MagicVision/CP14MagicVisionOverlay.cs index b49d714cec..68f7690b9b 100644 --- a/Content.Client/_CP14/MagicVision/CP14MagicVisionOverlay.cs +++ b/Content.Client/_CP14/MagicVision/CP14MagicVisionOverlay.cs @@ -1,6 +1,8 @@ using Content.Shared._CP14.MagicVision; +using Content.Shared.CCVar; using Robust.Client.Graphics; using Robust.Client.Player; +using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Prototypes; using Robust.Shared.Timing; @@ -9,6 +11,7 @@ namespace Content.Client._CP14.MagicVision; public sealed class CP14MagicVisionOverlay : Overlay { + [Dependency] private readonly IConfigurationManager _config = default!; [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; @@ -23,13 +26,15 @@ public sealed class CP14MagicVisionOverlay : Overlay public TimeSpan StartOverlay = TimeSpan.Zero; // when the overlay started private const float PowerDivisor = 250.0f; - private const float Intensity = 0.2f; // for adjusting the visual scale + private float _intensity = 0.2f; // for adjusting the visual scale private float _visualScale = 0; // between 0 and 1 public CP14MagicVisionOverlay() { IoCManager.InjectDependencies(this); _drowsinessShader = _prototypeManager.Index("Drowsiness").InstanceUnique(); + + _config.OnValueChanged(CCVars.ReducedMotion, OnReducedMotionChanged, invokeImmediately: true); } protected override void FrameUpdate(FrameEventArgs args) @@ -45,7 +50,7 @@ public sealed class CP14MagicVisionOverlay : Overlay var curTime = _timing.CurTime; var timeLeft = (float)(curTime - StartOverlay).TotalSeconds; - CurrentPower = Math.Max(50f, 200f - (150f * Math.Min((float)(timeLeft / 3.0), 1.0f))); + CurrentPower = Math.Min(150f, 150f / Math.Max((float)timeLeft * 1.8f, 1.0f)); } protected override bool BeforeDraw(in OverlayDrawArgs args) @@ -57,7 +62,12 @@ public sealed class CP14MagicVisionOverlay : Overlay return false; _visualScale = Math.Clamp(CurrentPower / PowerDivisor, 0.0f, 1.0f); - return _visualScale > 0; + return _visualScale >= 0; + } + + private void OnReducedMotionChanged(bool reducedMotion) + { + _intensity = reducedMotion ? 0f : 0.2f; } protected override void Draw(in OverlayDrawArgs args) @@ -67,7 +77,7 @@ public sealed class CP14MagicVisionOverlay : Overlay var handle = args.WorldHandle; _drowsinessShader.SetParameter("SCREEN_TEXTURE", ScreenTexture); - _drowsinessShader.SetParameter("Strength", _visualScale * Intensity); + _drowsinessShader.SetParameter("Strength", _visualScale * _intensity); handle.UseShader(_drowsinessShader); handle.DrawRect(args.WorldBounds, Color.White); handle.UseShader(null);