]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Scale radiation intensity with stack size (#19869)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Thu, 7 Sep 2023 21:59:08 +0000 (22:59 +0100)
committerGitHub <noreply@github.com>
Thu, 7 Sep 2023 21:59:08 +0000 (13:59 -0800)
Content.Server/Radiation/Systems/RadiationSystem.GridCast.cs
Resources/Prototypes/Entities/Objects/Materials/materials.yml

index c4a6a67033e8acd682240c405a5b15f543cbdbe7..8edb6c145565fc84bc467a1848dc20a824cb3261 100644 (file)
@@ -3,6 +3,7 @@ using Content.Server.Radiation.Components;
 using Content.Server.Radiation.Events;
 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.Map.Components;
@@ -14,6 +15,8 @@ namespace Content.Server.Radiation.Systems;
 // main algorithm that fire radiation rays to target
 public partial class RadiationSystem
 {
+    [Dependency] private readonly SharedStackSystem _stack = default!;
+
     private void UpdateGridcast()
     {
         // should we save debug information into rays?
@@ -23,19 +26,20 @@ public partial class RadiationSystem
         var stopwatch = new Stopwatch();
         stopwatch.Start();
 
-        var sources = EntityQuery<RadiationSourceComponent, TransformComponent>();
+        var sources = EntityQueryEnumerator<RadiationSourceComponent, TransformComponent>();
         var destinations = EntityQuery<RadiationReceiverComponent, TransformComponent>();
         var resistanceQuery = GetEntityQuery<RadiationGridResistanceComponent>();
         var transformQuery = GetEntityQuery<TransformComponent>();
         var gridQuery = GetEntityQuery<MapGridComponent>();
+        var stackQuery = GetEntityQuery<StackComponent>();
 
         // precalculate world positions for each source
         // so we won't need to calc this in cycle over and over again
-        var sourcesData = new ValueList<(RadiationSourceComponent, TransformComponent, Vector2)>();
-        foreach (var (source, sourceTrs) in sources)
+        var sourcesData = new ValueList<(EntityUid, RadiationSourceComponent, TransformComponent, Vector2)>();
+        while (sources.MoveNext(out var uid, out var source, out var sourceTrs))
         {
             var worldPos = _transform.GetWorldPosition(sourceTrs, transformQuery);
-            var data = (source, sourceTrs, worldPos);
+            var data = (uid, source, sourceTrs, worldPos);
             sourcesData.Add(data);
         }
 
@@ -47,12 +51,15 @@ public partial class RadiationSystem
             var destWorld = _transform.GetWorldPosition(destTrs, transformQuery);
 
             var rads = 0f;
-            foreach (var (source, sourceTrs, sourceWorld) in sourcesData)
+            foreach (var (uid, source, sourceTrs, sourceWorld) in sourcesData)
             {
+                stackQuery.TryGetComponent(uid, out var stack);
+                var intensity = source.Intensity * _stack.GetCount(uid, stack);
+
                 // send ray towards destination entity
-                var ray = Irradiate(sourceTrs.Owner, sourceTrs, sourceWorld,
+                var ray = Irradiate(uid, sourceTrs, sourceWorld,
                     destTrs.Owner, destTrs, destWorld,
-                    source.Intensity, source.Slope, saveVisitedTiles, resistanceQuery, transformQuery, gridQuery);
+                    intensity, source.Slope, saveVisitedTiles, resistanceQuery, transformQuery, gridQuery);
                 if (ray == null)
                     continue;
 
index 59bfb21373a0a1f456cdca5965b1f70195157641..35b90996fa81a873c6a65dd339b070c5a5db7c48 100644 (file)
       - bananium
       - bananium_1
   - type: RadiationSource
-    intensity: 0.3
+    intensity: 0.1
   - type: FlavorProfile
     flavors:
       - banana