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

@@ -5,16 +5,17 @@ using Content.Shared.Ghost;
using Content.Shared.Throwing;
using Robust.Shared.Map;
using Content.Shared.Physics;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
namespace Content.Shared.Anomaly.Effects;
public abstract class SharedGravityAnomalySystem : EntitySystem
{
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly SharedTransformSystem _xform = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
/// <inheritdoc/>
public override void Initialize()
@@ -47,13 +48,18 @@ public abstract class SharedGravityAnomalySystem : EntitySystem
private void OnSupercritical(EntityUid uid, GravityAnomalyComponent component, ref AnomalySupercriticalEvent args)
{
var xform = Transform(uid);
if (!_map.TryGetGrid(xform.GridUid, out var grid))
if (!TryComp(xform.GridUid, out MapGridComponent? grid))
return;
var worldPos = _xform.GetWorldPosition(xform);
var tileref = grid.GetTilesIntersecting(new Circle(worldPos, component.SpaceRange)).ToArray();
var tileref = _mapSystem.GetTilesIntersecting(
xform.GridUid.Value,
grid,
new Circle(worldPos, component.SpaceRange))
.ToArray();
var tiles = tileref.Select(t => (t.GridIndices, Tile.Empty)).ToList();
grid.SetTiles(tiles);
_mapSystem.SetTiles(xform.GridUid.Value, grid, tiles);
var range = component.MaxThrowRange * 2;
var strength = component.MaxThrowStrength * 2;