From 77cc81d37617cccb02245c070ce70d0027ec8483 Mon Sep 17 00:00:00 2001 From: Ed <96445749+TheShuEd@users.noreply.github.com> Date: Tue, 2 Jan 2024 03:30:05 +0300 Subject: [PATCH] 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> --- .../Anomaly/AnomalySystem.Generator.cs | 21 ++++++++++++ .../Components/AntiAnomalyZoneComponent.cs | 15 +++++++++ .../Entities/Markers/anti_anomaly_zone.yml | 33 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 Content.Server/Anomaly/Components/AntiAnomalyZoneComponent.cs create mode 100644 Resources/Prototypes/Entities/Markers/anti_anomaly_zone.yml diff --git a/Content.Server/Anomaly/AnomalySystem.Generator.cs b/Content.Server/Anomaly/AnomalySystem.Generator.cs index 769558a7ad..4afec04874 100644 --- a/Content.Server/Anomaly/AnomalySystem.Generator.cs +++ b/Content.Server/Anomaly/AnomalySystem.Generator.cs @@ -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; /// public sealed partial class AnomalySystem { + + [Dependency] private readonly SharedTransformSystem _transform = default!; + private void InitializeGenerator() { SubscribeLocalEvent(OnGeneratorBUIOpened); @@ -128,6 +133,22 @@ public sealed partial class AnomalySystem if (!valid) continue; + // don't spawn in AntiAnomalyZones + var antiAnomalyZonesQueue = AllEntityQuery(); + 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; } diff --git a/Content.Server/Anomaly/Components/AntiAnomalyZoneComponent.cs b/Content.Server/Anomaly/Components/AntiAnomalyZoneComponent.cs new file mode 100644 index 0000000000..68dcb51e48 --- /dev/null +++ b/Content.Server/Anomaly/Components/AntiAnomalyZoneComponent.cs @@ -0,0 +1,15 @@ + +namespace Content.Server.Anomaly.Components; + +/// +/// prohibits the possibility of anomalies appearing in the specified radius around the entity +/// +[RegisterComponent, Access(typeof(AnomalySystem))] +public sealed partial class AntiAnomalyZoneComponent : Component +{ + /// + /// the radius in which anomalies cannot appear + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public float ZoneRadius = 10; +} diff --git a/Resources/Prototypes/Entities/Markers/anti_anomaly_zone.yml b/Resources/Prototypes/Entities/Markers/anti_anomaly_zone.yml new file mode 100644 index 0000000000..fbc183613c --- /dev/null +++ b/Resources/Prototypes/Entities/Markers/anti_anomaly_zone.yml @@ -0,0 +1,33 @@ +- type: entity + name: anti anomaly zone + description: Anomalies will not be able to appear within a 10 block radius of this point. + id: AntiAnomalyZone + suffix: "range 10" + parent: MarkerBase + components: + - type: Sprite + sprite: Structures/Specific/Anomalies/ice_anom.rsi + layers: + - state: anom + - sprite: Markers/cross.rsi + state: pink + - type: AntiAnomalyZone + zoneRadius: 10 + +- type: entity + parent: AntiAnomalyZone + id: AntiAnomalyZone20 + suffix: "range 20" + description: Anomalies will not be able to appear within a 20 block radius of this point. + components: + - type: AntiAnomalyZone + zoneRadius: 20 + +- type: entity + parent: AntiAnomalyZone + id: AntiAnomalyZone50 + suffix: "range 50" + description: Anomalies will not be able to appear within a 50 block radius of this point. + components: + - type: AntiAnomalyZone + zoneRadius: 50 \ No newline at end of file -- 2.51.2