Code Cleanup: Puddles and Spreaders (#39)

# Description

Ports https://github.com/space-wizards/space-station-14/pull/26102.

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
This commit is contained in:
stellar-novas
2024-03-27 19:19:13 -04:00
committed by GitHub
parent f1b5baa944
commit b702cbd41d
6 changed files with 65 additions and 60 deletions

View File

@@ -13,9 +13,11 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly PuddleSystem _puddle = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedMapSystem _map = default!;
private readonly HashSet<ICommonSession> _playerObservers = new();
private List<Entity<MapGridComponent>> _grids = new();
private readonly HashSet<ICommonSession> _playerObservers = [];
private List<Entity<MapGridComponent>> _grids = [];
public bool ToggleObserver(ICommonSession observer)
{
@@ -55,7 +57,8 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
var transform = EntityManager.GetComponent<TransformComponent>(entity);
var worldBounds = Box2.CenteredAround(transform.WorldPosition,
var worldBounds = Box2.CenteredAround(_transform.GetWorldPosition(transform),
new Vector2(LocalViewRange, LocalViewRange));
_grids.Clear();
@@ -69,14 +72,14 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
if (!Exists(gridUid))
continue;
foreach (var uid in grid.Comp.GetAnchoredEntities(worldBounds))
foreach (var uid in _map.GetAnchoredEntities(gridUid, grid, worldBounds))
{
PuddleComponent? puddle = null;
TransformComponent? xform = null;
if (!Resolve(uid, ref puddle, ref xform, false))
continue;
var pos = xform.Coordinates.ToVector2i(EntityManager, _mapManager);
var pos = xform.Coordinates.ToVector2i(EntityManager, _mapManager, _transform);
var vol = _puddle.CurrentVolume(uid, puddle);
data.Add(new PuddleDebugOverlayData(pos, vol));
}