Optimise explosive depressurisation (#2190)
Slight increase. My whole life is staring at a profiler now. Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ using Content.Shared.Maps;
|
||||
using Robust.Server.GameObjects.EntitySystems.TileLookup;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Utility
|
||||
@@ -29,12 +30,8 @@ namespace Content.Server.Utility
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static IEnumerable<IEntity> GetEntitiesInTileFast(this MapIndices indices, GridId gridId, GridTileLookupSystem? gridTileLookup = null)
|
||||
{
|
||||
var turf = indices.GetTileRef(gridId);
|
||||
|
||||
if (turf == null)
|
||||
return Enumerable.Empty<IEntity>();
|
||||
|
||||
return GetEntitiesInTileFast(turf.Value, gridTileLookup);
|
||||
gridTileLookup ??= EntitySystem.Get<GridTileLookupSystem>();
|
||||
return gridTileLookup.GetEntitiesIntersecting(gridId, indices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ namespace Content.Shared.Maps
|
||||
/// <summary>
|
||||
/// Attempts to get the turf at map indices with grid id or null if no such turf is found.
|
||||
/// </summary>
|
||||
public static TileRef? GetTileRef(this MapIndices mapIndices, GridId gridId)
|
||||
public static TileRef? GetTileRef(this MapIndices mapIndices, GridId gridId, IMapManager mapManager = null)
|
||||
{
|
||||
if (!gridId.IsValid())
|
||||
return null;
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user