Screen Shake Intensity Slider in Accessibility Settings (#24749)
* Reduced motion toggle disables screen shake * Actually, screen shake is its own slider instead * Cache screen shake intensity cvar
This commit is contained in:
@@ -1,14 +1,34 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Camera;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Client.Camera;
|
||||
|
||||
public sealed class CameraRecoilSystem : SharedCameraRecoilSystem
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
||||
|
||||
protected float Intensity;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeNetworkEvent<CameraKickEvent>(OnCameraKick);
|
||||
|
||||
_configManager.OnValueChanged(CCVars.ScreenShakeIntensity, OnCvarChanged, true);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
_configManager.UnsubValueChanged(CCVars.ScreenShakeIntensity, OnCvarChanged);
|
||||
}
|
||||
|
||||
private void OnCvarChanged(float value)
|
||||
{
|
||||
Intensity = value;
|
||||
}
|
||||
|
||||
private void OnCameraKick(CameraKickEvent ev)
|
||||
@@ -18,9 +38,14 @@ public sealed class CameraRecoilSystem : SharedCameraRecoilSystem
|
||||
|
||||
public override void KickCamera(EntityUid uid, Vector2 recoil, CameraRecoilComponent? component = null)
|
||||
{
|
||||
if (Intensity == 0)
|
||||
return;
|
||||
|
||||
if (!Resolve(uid, ref component, false))
|
||||
return;
|
||||
|
||||
recoil *= Intensity;
|
||||
|
||||
// Use really bad math to "dampen" kicks when we're already kicked.
|
||||
var existing = component.CurrentKick.Length();
|
||||
var dampen = existing / KickMagnitudeMax;
|
||||
|
||||
Reference in New Issue
Block a user