Cleanup warning in GridInRange (#37699)

Cleanup warning in GridInRange
This commit is contained in:
Tayrtahn
2025-05-21 21:28:42 -04:00
committed by GitHub
parent 5af5305d97
commit 11f291d1a2

View File

@@ -1,5 +1,6 @@
using System.Numerics;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
namespace Content.Shared.Random.Rules;
@@ -11,6 +12,8 @@ public sealed partial class GridInRangeRule : RulesRule
[DataField]
public float Range = 10f;
private List<Entity<MapGridComponent>> _grids = [];
public override bool Check(EntityManager entManager, EntityUid uid)
{
if (!entManager.TryGetComponent(uid, out TransformComponent? xform))
@@ -29,10 +32,10 @@ public sealed partial class GridInRangeRule : RulesRule
var worldPos = transform.GetWorldPosition(xform);
var gridRange = new Vector2(Range, Range);
foreach (var _ in mapManager.FindGridsIntersecting(xform.MapID, new Box2(worldPos - gridRange, worldPos + gridRange)))
{
_grids.Clear();
mapManager.FindGridsIntersecting(xform.MapID, new Box2(worldPos - gridRange, worldPos + gridRange), ref _grids);
if (_grids.Count > 0)
return !Inverted;
}
return Inverted;
}