Code cleanup: puddles and spreaders (#26102)
* Removed obsolete MapManager calls * More code cleanup * EnsureComp * Rerun tests
This commit is contained in:
@@ -13,7 +13,7 @@ using Content.Shared.Database;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Smoking;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
@@ -35,7 +35,7 @@ public sealed class SmokeSystem : EntitySystem
|
||||
// If I could do it all again this could probably use a lot more of puddles.
|
||||
[Dependency] private readonly IAdminLogManager _logger = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
||||
@@ -45,7 +45,6 @@ public sealed class SmokeSystem : EntitySystem
|
||||
[Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
||||
[Dependency] private readonly TransformSystem _transform = default!;
|
||||
|
||||
private EntityQuery<SmokeComponent> _smokeQuery;
|
||||
private EntityQuery<SmokeAffectedComponent> _smokeAffectedQuery;
|
||||
@@ -137,7 +136,7 @@ public sealed class SmokeSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.NeighborFreeTiles.Any())
|
||||
if (args.NeighborFreeTiles.Count == 0)
|
||||
return;
|
||||
|
||||
TryComp<TimedDespawnComponent>(entity, out var timer);
|
||||
@@ -146,10 +145,10 @@ public sealed class SmokeSystem : EntitySystem
|
||||
var smokePerSpread = entity.Comp.SpreadAmount / Math.Max(1, args.NeighborFreeTiles.Count);
|
||||
foreach (var neighbor in args.NeighborFreeTiles)
|
||||
{
|
||||
var coords = neighbor.Grid.GridTileToLocal(neighbor.Tile);
|
||||
var coords = _map.GridTileToLocal(neighbor.Tile.GridUid, neighbor.Grid, neighbor.Tile.GridIndices);
|
||||
var ent = Spawn(prototype.ID, coords);
|
||||
var spreadAmount = Math.Max(0, smokePerSpread);
|
||||
entity.Comp.SpreadAmount -= args.NeighborFreeTiles.Count();
|
||||
entity.Comp.SpreadAmount -= args.NeighborFreeTiles.Count;
|
||||
|
||||
StartSmoke(ent, solution.Clone(), timer?.Lifetime ?? entity.Comp.Duration, spreadAmount);
|
||||
|
||||
@@ -305,10 +304,10 @@ public sealed class SmokeSystem : EntitySystem
|
||||
if (!_solutionContainerSystem.ResolveSolution(uid, SmokeComponent.SolutionName, ref component.Solution, out var solution) || !solution.Any())
|
||||
return;
|
||||
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out var mapGrid))
|
||||
if (!TryComp<MapGridComponent>(xform.GridUid, out var mapGrid))
|
||||
return;
|
||||
|
||||
var tile = mapGrid.GetTileRef(xform.Coordinates.ToVector2i(EntityManager, _mapManager, _transform));
|
||||
var tile = _map.GetTileRef(xform.GridUid.Value, mapGrid, xform.Coordinates);
|
||||
|
||||
foreach (var reagentQuantity in solution.Contents.ToArray())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user