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.Server.GameObjects.EntitySystems.TileLookup;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.Map;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
namespace Content.Server.Utility
|
namespace Content.Server.Utility
|
||||||
@@ -29,12 +30,8 @@ namespace Content.Server.Utility
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static IEnumerable<IEntity> GetEntitiesInTileFast(this MapIndices indices, GridId gridId, GridTileLookupSystem? gridTileLookup = null)
|
public static IEnumerable<IEntity> GetEntitiesInTileFast(this MapIndices indices, GridId gridId, GridTileLookupSystem? gridTileLookup = null)
|
||||||
{
|
{
|
||||||
var turf = indices.GetTileRef(gridId);
|
gridTileLookup ??= EntitySystem.Get<GridTileLookupSystem>();
|
||||||
|
return gridTileLookup.GetEntitiesIntersecting(gridId, indices);
|
||||||
if (turf == null)
|
|
||||||
return Enumerable.Empty<IEntity>();
|
|
||||||
|
|
||||||
return GetEntitiesInTileFast(turf.Value, gridTileLookup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ namespace Content.Shared.Maps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to get the turf at map indices with grid id or null if no such turf is found.
|
/// Attempts to get the turf at map indices with grid id or null if no such turf is found.
|
||||||
/// </summary>
|
/// </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())
|
if (!gridId.IsValid())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||||
|
|
||||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user