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

@@ -109,7 +109,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
UpdatesOutsidePrediction = true;
UpdatesAfter.Add(typeof(SharedEyeSystem));
_cfgMan.OnValueChanged(CCVars.DragDropDeadZone, SetDeadZone, true);
Subs.CVar(_cfgMan, CCVars.DragDropDeadZone, SetDeadZone, true);
_dropTargetInRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetInRange).Instance();
_dropTargetOutOfRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetOutOfRange).Instance();
@@ -126,7 +126,6 @@ public sealed class DragDropSystem : SharedDragDropSystem
public override void Shutdown()
{
_cfgMan.UnsubValueChanged(CCVars.DragDropDeadZone, SetDeadZone);
CommandBinds.Unregister<DragDropSystem>();
base.Shutdown();
}
@@ -269,7 +268,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
return false;
}
var player = _playerManager.LocalPlayer?.ControlledEntity;
var player = _playerManager.LocalEntity;
// still in range of the thing we are dragging?
if (player == null || !_interactionSystem.InRangeUnobstructed(player.Value, _draggedEntity.Value))
@@ -346,7 +345,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
return false;
}
var localPlayer = _playerManager.LocalPlayer?.ControlledEntity;
var localPlayer = _playerManager.LocalEntity;
if (localPlayer == null || !Exists(_draggedEntity))
{
@@ -410,7 +409,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
return;
}
var user = _playerManager.LocalPlayer?.ControlledEntity;
var user = _playerManager.LocalEntity;
if (user == null)
return;