]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Artifact containers can safely store radioactive objects (version 2) (#19652)
authorchromiumboy <50505512+chromiumboy@users.noreply.github.com>
Mon, 11 Sep 2023 19:58:25 +0000 (14:58 -0500)
committerGitHub <noreply@github.com>
Mon, 11 Sep 2023 19:58:25 +0000 (15:58 -0400)
* Artifact containers suppress the radioactive of artifacts inside them

* Updated to reflect changes to RobustToolbox

* Made necessary changes after updating RT

* Removed test code

* Made requested change

* Updated due to changes to RobustToolbox

* Renamed function

* Updated to accommodate changes to RobustToolbox

* Actually resolve merge conflict?

* Removed unnecessary change

* Made requested changes

* retrigger checks

* Retrigger checks

---------

Co-authored-by: root <root@DESKTOP-HJPF29C>
Content.Server/Radiation/Components/RadiationBlockingContainerComponent.cs [new file with mode: 0644]
Content.Server/Radiation/Systems/RadiationSystem.GridCast.cs
Resources/Prototypes/Catalog/Fills/Boxes/general.yml
Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifact_equipment.yml

diff --git a/Content.Server/Radiation/Components/RadiationBlockingContainerComponent.cs b/Content.Server/Radiation/Components/RadiationBlockingContainerComponent.cs
new file mode 100644 (file)
index 0000000..1a23671
--- /dev/null
@@ -0,0 +1,17 @@
+using Content.Server.Radiation.Systems;
+
+namespace Content.Server.Radiation.Components;
+
+/// <summary>
+///     Prevents entities from emitting or receiving radiation when placed inside this container.
+/// </summary>
+[RegisterComponent]
+[Access(typeof(RadiationSystem))]
+public sealed partial class RadiationBlockingContainerComponent : Component
+{
+    /// <summary>
+    ///     How many rads per second does the blocker absorb?
+    /// </summary>
+    [DataField("resistance")]
+    public float RadResistance = 1f;
+}
index 719b3fc1ca0c0d354705c282a4de4228d107d448..fa132186a97854b0c021effb3179700c6162686c 100644 (file)
@@ -5,10 +5,11 @@ using Content.Shared.Radiation.Components;
 using Content.Shared.Radiation.Systems;
 using Content.Shared.Stacks;
 using Robust.Shared.Collections;
-using Robust.Shared.Map;
+using Robust.Shared.Containers;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
+using System.Linq;
 
 namespace Content.Server.Radiation.Systems;
 
@@ -16,6 +17,9 @@ namespace Content.Server.Radiation.Systems;
 public partial class RadiationSystem
 {
     [Dependency] private readonly SharedStackSystem _stack = default!;
+    [Dependency] private readonly SharedContainerSystem _container = default!;
+
+    private EntityQuery<RadiationBlockingContainerComponent> _radiationBlockingContainers;
 
     private void UpdateGridcast()
     {
@@ -33,6 +37,8 @@ public partial class RadiationSystem
         var gridQuery = GetEntityQuery<MapGridComponent>();
         var stackQuery = GetEntityQuery<StackComponent>();
 
+        _radiationBlockingContainers = GetEntityQuery<RadiationBlockingContainerComponent>();
+
         // precalculate world positions for each source
         // so we won't need to calc this in cycle over and over again
         var sourcesData = new ValueList<(EntityUid, RadiationSourceComponent, TransformComponent, Vector2)>();
@@ -71,6 +77,9 @@ public partial class RadiationSystem
                     rads += ray.Rads;
             }
 
+            // Apply modifier if the destination entity is hidden within a radiation blocking container
+            rads = GetAdjustedRadiationIntensity(dest.Owner, rads);
+
             receiversTotalRads.Add((dest, rads));
         }
 
@@ -89,7 +98,7 @@ public partial class RadiationSystem
 
             // also send an event with combination of total rad
             if (rads > 0)
-                IrradiateEntity(receiver.Owner, rads,GridcastUpdateRate);
+                IrradiateEntity(receiver.Owner, rads, GridcastUpdateRate);
         }
 
         // raise broadcast event that radiation system has updated
@@ -114,8 +123,13 @@ public partial class RadiationSystem
         // check if receiver is too far away
         if (dist > GridcastMaxDistance)
             return null;
+
         // will it even reach destination considering distance penalty
         var rads = incomingRads - slope * dist;
+
+        // Apply rad modifier if the source is enclosed within a radiation blocking container
+        rads = GetAdjustedRadiationIntensity(sourceUid, rads);
+
         if (rads <= MinIntensity)
             return null;
 
@@ -218,4 +232,15 @@ public partial class RadiationSystem
 
         return ray;
     }
+
+    private float GetAdjustedRadiationIntensity(EntityUid uid, float rads)
+    {
+        var radblockingComps = new List<RadiationBlockingContainerComponent>();
+        if (_container.TryFindComponentsOnEntityContainerOrParent(uid, _radiationBlockingContainers, radblockingComps))
+        {
+            rads -= radblockingComps.Sum(x => x.RadResistance);
+        }
+
+        return float.Max(rads, 0);
+    }
 }
index 469496623271be3d09931bda62e0018f662998f0..78d04343b69beca567cabcf3f6975fdbbd117305 100644 (file)
     layers:
       - state: box
       - state: syringe
+
+- type: entity
+  name: lead-lined box
+  parent: BoxCardboard
+  suffix: Debug
+  id: BoxLeadLined
+  description: This box stymies the transmission of harmful radiation.
+  components:
+  - type: Sprite
+    state: box
+  - type: RadiationBlockingContainer
+    resistance: 2
\ No newline at end of file
index 18ffe0fb054f0dc58b944fcc1d894587abb1fa87..e03d94c53c457809896d6058d70490c644a3f2a7 100644 (file)
@@ -44,6 +44,8 @@
         - Artifact
     - type: Weldable
     - type: SuppressArtifactContainer
+    - type: RadiationBlockingContainer
+      resistance: 5
     - type: PlaceableSurface
       isPlaceable: false
     - type: Damageable