From 5f7b756cbe5b8c1c5bcbc823ff4d57be91552a6f Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 29 May 2023 15:48:58 +1000 Subject: [PATCH] Another rules change (#16920) --- Content.Shared/Random/RulesSystem.cs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Content.Shared/Random/RulesSystem.cs b/Content.Shared/Random/RulesSystem.cs index d4f2c6e9d1..54ddc8348d 100644 --- a/Content.Shared/Random/RulesSystem.cs +++ b/Content.Shared/Random/RulesSystem.cs @@ -179,24 +179,44 @@ public sealed class RulesSystem : EntitySystem return false; } + var physicsQuery = GetEntityQuery(); var tileCount = 0; var matchingTileCount = 0; foreach (var tile in grid.GetTilesIntersecting(new Circle(_transform.GetWorldPosition(xform), tiles.Range))) { + // Only consider collidable anchored (for reasons some subfloor stuff has physics but non-collidable) + if (tiles.IgnoreAnchored) + { + var gridEnum = grid.GetAnchoredEntitiesEnumerator(tile.GridIndices); + var found = false; + + while (gridEnum.MoveNext(out var ancUid)) + { + if (!physicsQuery.TryGetComponent(ancUid, out var physics) || + !physics.CanCollide) + { + continue; + } + + found = true; + break; + } + + if (found) + continue; + } + tileCount++; if (!tiles.Tiles.Contains(_tileDef[tile.Tile.TypeId].ID)) continue; - if (tiles.IgnoreAnchored && grid.GetAnchoredEntitiesEnumerator(tile.GridIndices).MoveNext(out _)) - continue; - matchingTileCount++; } - if (matchingTileCount / (float) tileCount < tiles.Percent) + if (tileCount == 0 || matchingTileCount / (float) tileCount < tiles.Percent) return false; break;