]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix anti-anomaly zones (#23357)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Tue, 2 Jan 2024 06:18:41 +0000 (01:18 -0500)
committerGitHub <noreply@github.com>
Tue, 2 Jan 2024 06:18:41 +0000 (17:18 +1100)
Content.Server/Anomaly/AnomalySystem.Generator.cs

index 4afec04874eadfbdc895fe489e5cb774ef330a27..61bb356ff769b6c83a937e0011d0fc29fa6b6edc 100644 (file)
@@ -13,6 +13,7 @@ using Robust.Shared.Physics;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Map;
 using System.Numerics;
+using Robust.Server.GameObjects;
 
 namespace Content.Server.Anomaly;
 
@@ -23,7 +24,7 @@ namespace Content.Server.Anomaly;
 /// </summary>
 public sealed partial class AnomalySystem
 {
-
+    [Dependency] private readonly MapSystem _mapSystem = default!;
     [Dependency] private readonly SharedTransformSystem _transform = default!;
 
     private void InitializeGenerator()
@@ -133,14 +134,19 @@ public sealed partial class AnomalySystem
             if (!valid)
                 continue;
 
+            var pos = _mapSystem.GridTileToLocal(grid, gridComp, tile);
+            var mapPos = pos.ToMap(EntityManager, _transform);
             // don't spawn in AntiAnomalyZones
-            var antiAnomalyZonesQueue = AllEntityQuery<AntiAnomalyZoneComponent>();
-            while (antiAnomalyZonesQueue.MoveNext(out var uid, out var zone))
+            var antiAnomalyZonesQueue = AllEntityQuery<AntiAnomalyZoneComponent, TransformComponent>();
+            while (antiAnomalyZonesQueue.MoveNext(out var uid, out var zone, out var antiXform))
             {
-                var zoneTile = _transform.GetGridTilePositionOrDefault(uid, gridComp);
+                if (antiXform.MapID != mapPos.MapId)
+                    continue;
+
+                var antiCoordinates = _transform.GetMapCoordinates(antiXform);
 
-                var delta = (zoneTile - tile);
-                if (delta.LengthSquared < zone.ZoneRadius * zone.ZoneRadius)
+                var delta = antiCoordinates.Position - mapPos.Position;
+                if (delta.LengthSquared() < zone.ZoneRadius * zone.ZoneRadius)
                 {
                     valid = false;
                     break;
@@ -149,7 +155,7 @@ public sealed partial class AnomalySystem
             if (!valid)
                 continue;
 
-            targetCoords = gridComp.GridTileToLocal(tile);
+            targetCoords = pos;
             break;
         }