Fix anti-anomaly zones (#23357)

This commit is contained in:
Nemanja
2024-01-02 01:18:41 -05:00
committed by GitHub
parent 76bae5a17a
commit 2988d60bd4

View 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 delta = (zoneTile - tile);
if (delta.LengthSquared < zone.ZoneRadius * zone.ZoneRadius)
var antiCoordinates = _transform.GetMapCoordinates(antiXform);
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;
}