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

@@ -40,17 +40,10 @@ public sealed class InteractionOutlineSystem : EntitySystem
{
base.Initialize();
_configManager.OnValueChanged(CCVars.OutlineEnabled, SetCvarEnabled);
Subs.CVar(_configManager, CCVars.OutlineEnabled, SetCvarEnabled);
UpdatesAfter.Add(typeof(SharedEyeSystem));
}
public override void Shutdown()
{
base.Shutdown();
_configManager.UnsubValueChanged(CCVars.OutlineEnabled, SetCvarEnabled);
}
public void SetCvarEnabled(bool cvarEnabled)
{
_cvarEnabled = cvarEnabled;
@@ -94,8 +87,8 @@ public sealed class InteractionOutlineSystem : EntitySystem
return;
// If there is no local player, there is no session, and therefore nothing to do here.
var localPlayer = _playerManager.LocalPlayer;
if (localPlayer == null)
var localSession = _playerManager.LocalSession;
if (localSession == null)
return;
// TODO InteractionOutlineComponent
@@ -135,9 +128,9 @@ public sealed class InteractionOutlineSystem : EntitySystem
}
var inRange = false;
if (localPlayer.ControlledEntity != null && !Deleted(entityToClick))
if (localSession.AttachedEntity != null && !Deleted(entityToClick))
{
inRange = _interactionSystem.InRangeUnobstructed(localPlayer.ControlledEntity.Value, entityToClick.Value);
inRange = _interactionSystem.InRangeUnobstructed(localSession.AttachedEntity.Value, entityToClick.Value);
}
InteractionOutlineComponent? outline;