Fix misc. flesh anomaly exceptions (#15750)

This commit is contained in:
Nemanja 2023-04-24 21:13:44 -04:00 • committed by GitHub
parent c7ba2a666b
commit 6abe83cb43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,12 +63,19 @@ public sealed class FleshAnomalySystem : EntitySystem
private void SpawnMonstersOnOpenTiles(FleshAnomalyComponent component, TransformComponent xform, int amount, float radius)
{
if (!component.Spawns.Any())
return;
if (!_map.TryGetGrid(xform.GridUid, out var grid))
return;
var localpos = xform.Coordinates.Position;
var tilerefs = grid.GetLocalTilesIntersecting(
new Box2(localpos + (-radius, -radius), localpos + (radius, radius))).ToArray();
if (tilerefs.Length == 0)
return;
_random.Shuffle(tilerefs);
var physQuery = GetEntityQuery<PhysicsComponent>();
var amountCounter = 0;