Random spontaneous cleanup PR (#25131)

* Use new Subs.CVar helper

Removes manual config OnValueChanged calls, removes need to remember to manually unsubscribe.

This both reduces boilerplate and fixes many issues where subscriptions weren't removed on entity system shutdown.

* Fix a bunch of warnings

* More warning fixes

* Use new DateTime serializer to get rid of ISerializationHooks in changelog code.

* Get rid of some more ISerializationHooks for enums

* And a little more

* Apply suggestions from code review

Co-authored-by: 0x6273 <0x40@keemail.me>

---------

Co-authored-by: 0x6273 <0x40@keemail.me>
This commit is contained in:
Pieter-Jan Briers
2024-02-13 22:48:39 +01:00
committed by GitHub
parent d0c174388c
commit 68ce53ae17
210 changed files with 481 additions and 930 deletions

View File

@@ -9,26 +9,19 @@ public sealed class CameraRecoilSystem : SharedCameraRecoilSystem
{
[Dependency] private readonly IConfigurationManager _configManager = default!;
protected float Intensity;
private 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);
Subs.CVar(_configManager, CCVars.ScreenShakeIntensity, OnCvarChanged, true);
}
private void OnCvarChanged(float value)
{
Intensity = value;
_intensity = value;
}
private void OnCameraKick(CameraKickEvent ev)
@@ -38,13 +31,13 @@ public sealed class CameraRecoilSystem : SharedCameraRecoilSystem
public override void KickCamera(EntityUid uid, Vector2 recoil, CameraRecoilComponent? component = null)
{
if (Intensity == 0)
if (_intensity == 0)
return;
if (!Resolve(uid, ref component, false))
return;
recoil *= Intensity;
recoil *= _intensity;
// Use really bad math to "dampen" kicks when we're already kicked.
var existing = component.CurrentKick.Length();