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

@@ -28,7 +28,7 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
SubscribeLocalEvent<CombatModeComponent, AfterAutoHandleStateEvent>(OnHandleState);
_cfg.OnValueChanged(CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged, true);
Subs.CVar(_cfg, CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged, true);
}
private void OnHandleState(EntityUid uid, CombatModeComponent component, ref AfterAutoHandleStateEvent args)
@@ -38,7 +38,6 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
public override void Shutdown()
{
_cfg.UnsubValueChanged(CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged);
_overlayManager.RemoveOverlay<CombatModeIndicatorsOverlay>();
base.Shutdown();
@@ -46,7 +45,7 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
public bool IsInCombatMode()
{
var entity = _playerManager.LocalPlayer?.ControlledEntity;
var entity = _playerManager.LocalEntity;
if (entity == null)
return false;
@@ -67,7 +66,7 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
private void UpdateHud(EntityUid entity)
{
if (entity != _playerManager.LocalPlayer?.ControlledEntity || !Timing.IsFirstTimePredicted)
if (entity != _playerManager.LocalEntity || !Timing.IsFirstTimePredicted)
{
return;
}