Anti Anomaly zones (#23187)

* add

* its work now

* pipi

* Update Content.Server/Anomaly/AnomalySystem.Generator.cs

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>

* fix ()

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
Ed
2024-01-02 03:30:05 +03:00
committed by GitHub
parent 0ffd4e953e
commit 77cc81d376
3 changed files with 69 additions and 0 deletions

View File

@@ -11,6 +11,8 @@ using Content.Shared.Physics;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Map;
using System.Numerics;
namespace Content.Server.Anomaly;
@@ -21,6 +23,9 @@ namespace Content.Server.Anomaly;
/// </summary>
public sealed partial class AnomalySystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
private void InitializeGenerator()
{
SubscribeLocalEvent<AnomalyGeneratorComponent, BoundUIOpenedEvent>(OnGeneratorBUIOpened);
@@ -128,6 +133,22 @@ public sealed partial class AnomalySystem
if (!valid)
continue;
// don't spawn in AntiAnomalyZones
var antiAnomalyZonesQueue = AllEntityQuery<AntiAnomalyZoneComponent>();
while (antiAnomalyZonesQueue.MoveNext(out var uid, out var zone))
{
var zoneTile = _transform.GetGridTilePositionOrDefault(uid, gridComp);
var delta = (zoneTile - tile);
if (delta.LengthSquared < zone.ZoneRadius * zone.ZoneRadius)
{
valid = false;
break;
}
}
if (!valid)
continue;
targetCoords = gridComp.GridTileToLocal(tile);
break;
}