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:
parent
319821c3ff
commit
694ebfb72d
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue