Cherrypick: Makes singularities respect reduced motion option (#43362) (#5579)

Makes singularities respect reduced motion option (#43362)

* Makes singularities respect reduced motion option

* This seems better

* Apply suggestion from @slarticodefast

* Apply suggestion from @slarticodefast

* Apply suggestion from @slarticodefast

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
Minerva 2026-03-28 17:38:59 -04:00 committed by GitHub
parent 319821c3ff
commit 694ebfb72d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 1 deletions

View File

@ -1,9 +1,11 @@
using System.Numerics;
using Content.Shared.CCVar;
using Content.Shared.Singularity.Components;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using System.Numerics;
namespace Content.Client.Singularity
{
@ -13,6 +15,7 @@ namespace Content.Client.Singularity
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
private SharedTransformSystem? _xformSystem = null;
/// <summary>
@ -28,6 +31,8 @@ namespace Content.Client.Singularity
private readonly ShaderInstance _shader;
private bool _reducedMotion;
public SingularityOverlay()
{
IoCManager.InjectDependencies(this);
@ -35,6 +40,8 @@ namespace Content.Client.Singularity
_shader.SetParameter("maxDistance", MaxDistance * EyeManager.PixelsPerMeter);
_entMan.EventBus.SubscribeEvent<PixelToMapEvent>(EventSource.Local, this, OnProjectFromScreenToMap);
ZIndex = 101; // Should be drawn after the placement overlay so admins placing items near the singularity can tell where they're going.
_configManager.OnValueChanged(CCVars.ReducedMotion, (b) => { _reducedMotion = b; }, invokeImmediately: true);
}
private readonly Vector2[] _positions = new Vector2[MaxCount];
@ -44,6 +51,8 @@ namespace Content.Client.Singularity
protected override bool BeforeDraw(in OverlayDrawArgs args)
{
if (_reducedMotion)
return false;
if (args.Viewport.Eye == null)
return false;
if (_xformSystem is null && !_entMan.TrySystem(out _xformSystem))
@ -102,6 +111,8 @@ namespace Content.Client.Singularity
/// </summary>
private void OnProjectFromScreenToMap(ref PixelToMapEvent args)
{ // Mostly copypasta from the singularity shader.
if (_reducedMotion)
return;
if (args.Viewport.Eye == null)
return;
var maxDistance = MaxDistance * EyeManager.PixelsPerMeter;