diff --git a/Content.Client/Overlays/StencilOverlay.Weather.cs b/Content.Client/Overlays/StencilOverlay.Weather.cs index bc514548036384..ad69522dfdab0d 100644 --- a/Content.Client/Overlays/StencilOverlay.Weather.cs +++ b/Content.Client/Overlays/StencilOverlay.Weather.cs @@ -35,7 +35,7 @@ private void DrawWeather(in OverlayDrawArgs args, WeatherPrototype weatherProto, var matty = Matrix3x2.Multiply(matrix, invMatrix); worldHandle.SetTransform(matty); - foreach (var tile in grid.Comp.GetTilesIntersecting(worldAABB)) + foreach (var tile in _map.GetTilesIntersecting(grid.Owner, grid, worldAABB)) { // Ignored tiles for stencil if (_weather.CanWeatherAffect(grid.Owner, grid, tile)) diff --git a/Content.Client/Overlays/StencilOverlay.cs b/Content.Client/Overlays/StencilOverlay.cs index 78b1c4d2b15c7a..eb5c27156ed15e 100644 --- a/Content.Client/Overlays/StencilOverlay.cs +++ b/Content.Client/Overlays/StencilOverlay.cs @@ -24,6 +24,7 @@ public sealed partial class StencilOverlay : Overlay [Dependency] private readonly IPrototypeManager _protoManager = default!; private readonly ParallaxSystem _parallax; private readonly SharedTransformSystem _transform; + private readonly SharedMapSystem _map; private readonly SpriteSystem _sprite; private readonly WeatherSystem _weather; @@ -33,11 +34,12 @@ public sealed partial class StencilOverlay : Overlay private readonly ShaderInstance _shader; - public StencilOverlay(ParallaxSystem parallax, SharedTransformSystem transform, SpriteSystem sprite, WeatherSystem weather) + public StencilOverlay(ParallaxSystem parallax, SharedTransformSystem transform, SharedMapSystem map, SpriteSystem sprite, WeatherSystem weather) { ZIndex = ParallaxSystem.ParallaxZIndex + 1; _parallax = parallax; _transform = transform; + _map = map; _sprite = sprite; _weather = weather; IoCManager.InjectDependencies(this); diff --git a/Content.Client/Overlays/StencilOverlaySystem.cs b/Content.Client/Overlays/StencilOverlaySystem.cs index c8a9553cfdddf9..364ec0fddbf59e 100644 --- a/Content.Client/Overlays/StencilOverlaySystem.cs +++ b/Content.Client/Overlays/StencilOverlaySystem.cs @@ -10,13 +10,14 @@ public sealed class StencilOverlaySystem : EntitySystem [Dependency] private readonly IOverlayManager _overlay = default!; [Dependency] private readonly ParallaxSystem _parallax = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly SharedMapSystem _map = default!; [Dependency] private readonly SpriteSystem _sprite = default!; [Dependency] private readonly WeatherSystem _weather = default!; public override void Initialize() { base.Initialize(); - _overlay.AddOverlay(new StencilOverlay(_parallax, _transform, _sprite, _weather)); + _overlay.AddOverlay(new StencilOverlay(_parallax, _transform, _map, _sprite, _weather)); } public override void Shutdown() diff --git a/Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs b/Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs index 7fee8fdb98577f..b6bc012d83e41c 100644 --- a/Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs +++ b/Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs @@ -16,6 +16,7 @@ public sealed class GasProducerAnomalySystem : EntitySystem { [Dependency] private readonly AtmosphereSystem _atmosphere = default!; [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly SharedMapSystem _map = default!; public override void Initialize() { @@ -56,8 +57,11 @@ private void ReleaseGas(EntityUid uid, Gas gas, float mols, float radius, int co return; var localpos = xform.Coordinates.Position; - var tilerefs = grid.GetLocalTilesIntersecting( - new Box2(localpos + new Vector2(-radius, -radius), localpos + new Vector2(radius, radius))).ToArray(); + var tilerefs = _map.GetLocalTilesIntersecting( + xform.GridUid.Value, + grid, + new Box2(localpos + new Vector2(-radius, -radius), localpos + new Vector2(radius, radius))) + .ToArray(); if (tilerefs.Length == 0) return; diff --git a/Content.Server/Dragon/DragonSystem.cs b/Content.Server/Dragon/DragonSystem.cs index 42610a03237274..efac049b354d1a 100644 --- a/Content.Server/Dragon/DragonSystem.cs +++ b/Content.Server/Dragon/DragonSystem.cs @@ -28,6 +28,7 @@ public sealed partial class DragonSystem : EntitySystem [Dependency] private readonly SharedActionsSystem _actions = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly SharedMapSystem _map = default!; [Dependency] private readonly MobStateSystem _mobState = default!; private EntityQuery _objQuery; @@ -156,7 +157,7 @@ private void OnSpawnRift(EntityUid uid, DragonComponent component, DragonSpawnRi } // cant put a rift on solars - foreach (var tile in grid.GetTilesIntersecting(new Circle(_transform.GetWorldPosition(xform), RiftTileRadius), false)) + foreach (var tile in _map.GetTilesIntersecting(xform.GridUid.Value, grid, new Circle(_transform.GetWorldPosition(xform), RiftTileRadius), false)) { if (!tile.IsSpace(_tileDef)) continue; diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs index 38c1070a8ab6f4..ffeb852e8b5de9 100644 --- a/Content.Server/Nuke/NukeSystem.cs +++ b/Content.Server/Nuke/NukeSystem.cs @@ -40,6 +40,7 @@ public sealed class NukeSystem : EntitySystem [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly SharedMapSystem _map = default!; [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly UserInterfaceSystem _ui = default!; [Dependency] private readonly AppearanceSystem _appearance = default!; @@ -190,7 +191,7 @@ private async void OnAnchorButtonPressed(EntityUid uid, NukeComponent component, var worldPos = _transform.GetWorldPosition(xform); - foreach (var tile in grid.GetTilesIntersecting(new Circle(worldPos, component.RequiredFloorRadius), false)) + foreach (var tile in _map.GetTilesIntersecting(xform.GridUid.Value, grid, new Circle(worldPos, component.RequiredFloorRadius), false)) { if (!tile.IsSpace(_tileDefManager)) continue; diff --git a/Content.Server/Respawn/SpecialRespawnSystem.cs b/Content.Server/Respawn/SpecialRespawnSystem.cs index 6d398db259db25..a403818e7429bc 100644 --- a/Content.Server/Respawn/SpecialRespawnSystem.cs +++ b/Content.Server/Respawn/SpecialRespawnSystem.cs @@ -21,6 +21,7 @@ public sealed class SpecialRespawnSystem : SharedSpecialRespawnSystem [Dependency] private readonly AtmosphereSystem _atmosphere = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly SharedMapSystem _map = default!; [Dependency] private readonly TurfSystem _turf = default!; [Dependency] private readonly IChatManager _chat = default!; [Dependency] private readonly IPrototypeManager _proto = default!; @@ -105,7 +106,7 @@ private void OnTermination(EntityUid uid, SpecialRespawnComponent component, ref var found = false; - foreach (var tile in grid.GetTilesIntersecting(circle)) + foreach (var tile in _map.GetTilesIntersecting(entityGridUid.Value, grid, circle)) { if (tile.IsSpace(_tileDefinitionManager) || _turf.IsTileBlocked(tile, CollisionGroup.MobMask) @@ -176,7 +177,7 @@ public bool TryFindRandomTile(EntityUid targetGrid, EntityUid targetMap, int max var mapTarget = grid.WorldToTile(mapPos); var circle = new Circle(mapPos, 2); - foreach (var newTileRef in grid.GetTilesIntersecting(circle)) + foreach (var newTileRef in _map.GetTilesIntersecting(targetGrid, grid, circle)) { if (newTileRef.IsSpace(_tileDefinitionManager) || _turf.IsTileBlocked(newTileRef, CollisionGroup.MobMask) || !_atmosphere.IsTileMixtureProbablySafe(targetGrid, targetMap, mapTarget)) continue; diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs index f972865509edc0..6b83a61d2860b2 100644 --- a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs +++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs @@ -43,6 +43,7 @@ public sealed partial class RevenantSystem [Dependency] private readonly TileSystem _tile = default!; [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; + [Dependency] private readonly SharedMapSystem _mapSystem = default!; private void InitializeAbilities() { @@ -228,8 +229,12 @@ private void OnDefileAction(EntityUid uid, RevenantComponent component, Revenant var xform = Transform(uid); if (!TryComp(xform.GridUid, out var map)) return; - var tiles = map.GetTilesIntersecting(Box2.CenteredAround(_transformSystem.GetWorldPosition(xform), - new Vector2(component.DefileRadius * 2, component.DefileRadius))).ToArray(); + var tiles = _mapSystem.GetTilesIntersecting( + xform.GridUid.Value, + map, + Box2.CenteredAround(_transformSystem.GetWorldPosition(xform), + new Vector2(component.DefileRadius * 2, component.DefileRadius))) + .ToArray(); _random.Shuffle(tiles); diff --git a/Content.Server/Salvage/SpawnSalvageMissionJob.cs b/Content.Server/Salvage/SpawnSalvageMissionJob.cs index 31c6b73253dcdb..21da7e89a07e59 100644 --- a/Content.Server/Salvage/SpawnSalvageMissionJob.cs +++ b/Content.Server/Salvage/SpawnSalvageMissionJob.cs @@ -193,7 +193,7 @@ protected override async Task Process() List reservedTiles = new(); - foreach (var tile in grid.GetTilesIntersecting(new Circle(Vector2.Zero, landingPadRadius), false)) + foreach (var tile in _map.GetTilesIntersecting(mapUid, grid, new Circle(Vector2.Zero, landingPadRadius), false)) { if (!_biome.TryGetBiomeTile(mapUid, grid, tile.GridIndices, out _)) continue; diff --git a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs index bf5a45549ceb13..2a2952916ecdbd 100644 --- a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs @@ -308,7 +308,7 @@ public void ConsumeTilesInRange(EntityUid uid, float range, TransformComponent? foreach (var grid in grids) { // TODO: Remover grid.Owner when this iterator returns entityuids as well. - AttemptConsumeTiles(uid, grid.Comp.GetTilesIntersecting(circle), grid, grid, eventHorizon); + AttemptConsumeTiles(uid, _mapSystem.GetTilesIntersecting(grid.Owner, grid.Comp, circle), grid, grid, eventHorizon); } } diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs index 05912229960a95..7b8430dc480e9b 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs @@ -4,7 +4,6 @@ using Content.Shared.Maps; using Content.Shared.Physics; using Content.Shared.Throwing; -using Robust.Server.GameObjects; using Robust.Shared.Map.Components; using Robust.Shared.Physics.Components; using Robust.Shared.Random; @@ -17,7 +16,8 @@ public sealed class ThrowArtifactSystem : EntitySystem [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly ThrowingSystem _throwing = default!; [Dependency] private readonly TileSystem _tile = default!; - [Dependency] private readonly TransformSystem _transform = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly SharedMapSystem _mapSystem = default!; /// public override void Initialize() @@ -30,7 +30,9 @@ private void OnActivated(EntityUid uid, ThrowArtifactComponent component, Artifa var xform = Transform(uid); if (TryComp(xform.GridUid, out var grid)) { - var tiles = grid.GetTilesIntersecting( + var tiles = _mapSystem.GetTilesIntersecting( + xform.GridUid.Value, + grid, Box2.CenteredAround(_transform.GetWorldPosition(xform), new Vector2(component.Range * 2, component.Range))); foreach (var tile in tiles) diff --git a/Content.Shared/Anomaly/SharedAnomalySystem.cs b/Content.Shared/Anomaly/SharedAnomalySystem.cs index 00d97c1a46e659..05e12d406e2240 100644 --- a/Content.Shared/Anomaly/SharedAnomalySystem.cs +++ b/Content.Shared/Anomaly/SharedAnomalySystem.cs @@ -34,6 +34,7 @@ public abstract class SharedAnomalySystem : EntitySystem [Dependency] protected readonly SharedPopupSystem Popup = default!; [Dependency] private readonly IPrototypeManager _prototype = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly SharedMapSystem _map = default!; public override void Initialize() { @@ -358,8 +359,11 @@ public override void Update(float frameTime) var amount = (int) (MathHelper.Lerp(settings.MinAmount, settings.MaxAmount, severity * stability * powerModifier) + 0.5f); var localpos = xform.Coordinates.Position; - var tilerefs = grid.GetLocalTilesIntersecting( - new Box2(localpos + new Vector2(-settings.MaxRange, -settings.MaxRange), localpos + new Vector2(settings.MaxRange, settings.MaxRange))).ToList(); + var tilerefs = _map.GetLocalTilesIntersecting( + xform.GridUid.Value, + grid, + new Box2(localpos + new Vector2(-settings.MaxRange, -settings.MaxRange), localpos + new Vector2(settings.MaxRange, settings.MaxRange))) + .ToList(); if (tilerefs.Count == 0) return null; diff --git a/Content.Shared/Random/Rules/NearbyTilesPercent.cs b/Content.Shared/Random/Rules/NearbyTilesPercent.cs index 465ac8dc5c696e..8d6485dc7681f6 100644 --- a/Content.Shared/Random/Rules/NearbyTilesPercent.cs +++ b/Content.Shared/Random/Rules/NearbyTilesPercent.cs @@ -23,6 +23,8 @@ public sealed partial class NearbyTilesPercentRule : RulesRule [DataField] public float Range = 10f; + private readonly SharedMapSystem _map; + public override bool Check(EntityManager entManager, EntityUid uid) { if (!entManager.TryGetComponent(uid, out TransformComponent? xform) || @@ -38,7 +40,7 @@ public override bool Check(EntityManager entManager, EntityUid uid) var tileCount = 0; var matchingTileCount = 0; - foreach (var tile in grid.GetTilesIntersecting(new Circle(transform.GetWorldPosition(xform), + foreach (var tile in _map.GetTilesIntersecting(xform.GridUid.Value, grid, new Circle(transform.GetWorldPosition(xform), Range))) { // Only consider collidable anchored (for reasons some subfloor stuff has physics but non-collidable)