]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Anti Anomaly zones (#23187)
authorEd <96445749+TheShuEd@users.noreply.github.com>
Tue, 2 Jan 2024 00:30:05 +0000 (03:30 +0300)
committerGitHub <noreply@github.com>
Tue, 2 Jan 2024 00:30:05 +0000 (17:30 -0700)
* 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>
Content.Server/Anomaly/AnomalySystem.Generator.cs
Content.Server/Anomaly/Components/AntiAnomalyZoneComponent.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Markers/anti_anomaly_zone.yml [new file with mode: 0644]

index 769558a7ad13f204bb7b47bdb9c3ae32044cd1de..4afec04874eadfbdc895fe489e5cb774ef330a27 100644 (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;
         }
diff --git a/Content.Server/Anomaly/Components/AntiAnomalyZoneComponent.cs b/Content.Server/Anomaly/Components/AntiAnomalyZoneComponent.cs
new file mode 100644 (file)
index 0000000..68dcb51
--- /dev/null
@@ -0,0 +1,15 @@
+
+namespace Content.Server.Anomaly.Components;
+
+/// <summary>
+/// prohibits the possibility of anomalies appearing in the specified radius around the entity
+/// </summary>
+[RegisterComponent, Access(typeof(AnomalySystem))]
+public sealed partial class AntiAnomalyZoneComponent : Component
+{
+    /// <summary>
+    /// the radius in which anomalies cannot appear
+    /// </summary>
+    [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 (file)
index 0000000..fbc1836
--- /dev/null
@@ -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