diff --git a/Content.Server/Anomaly/Components/GasProducerAnomalyComponent.cs b/Content.Server/Anomaly/Components/GasProducerAnomalyComponent.cs
index 078f816542..5df429be46 100644
--- a/Content.Server/Anomaly/Components/GasProducerAnomalyComponent.cs
+++ b/Content.Server/Anomaly/Components/GasProducerAnomalyComponent.cs
@@ -3,7 +3,7 @@ using Content.Shared.Atmos;
namespace Content.Server.Anomaly.Components;
///
-/// This component is used for handling gas producing anomalies
+/// This component is used for handling gas producing anomalies. Will always spawn one on the tile with the anomaly, and in a random radius around it.
///
[RegisterComponent]
public sealed class GasProducerAnomalyComponent : Component
@@ -37,4 +37,22 @@ public sealed class GasProducerAnomalyComponent : Component
///
[DataField("passiveMoleAmount")]
public float PassiveMoleAmount = 1f;
+
+ ///
+ /// The radius of random gas spawns.
+ ///
+ [DataField("spawnRadius", required: true)]
+ public float spawnRadius = 3;
+
+ ///
+ /// The number of tiles which will be modified.
+ ///
+ [DataField("tileCount")]
+ public int tileCount = 1;
+
+ ///
+ /// The the amount the tempurature should be modified by (negative for decreasing temp)
+ ///
+ [DataField("tempChange")]
+ public float tempChange = 0;
}
diff --git a/Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs b/Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs
index 85119d8676..7dad392fbc 100644
--- a/Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs
+++ b/Content.Server/Anomaly/Effects/GasProducerAnomalySystem.cs
@@ -3,6 +3,9 @@ using Content.Server.Anomaly.Components;
using Content.Shared.Anomaly.Components;
using Content.Shared.Atmos;
using Robust.Server.GameObjects;
+using Robust.Shared.Map;
+using Robust.Shared.Random;
+using System.Linq;
namespace Content.Server.Anomaly.Effects;
@@ -13,6 +16,8 @@ public sealed class GasProducerAnomalySystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly TransformSystem _xform = default!;
+ [Dependency] private readonly IMapManager _map = default!;
+ [Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
@@ -25,7 +30,7 @@ public sealed class GasProducerAnomalySystem : EntitySystem
if (!component.ReleaseOnMaxSeverity)
return;
- ReleaseGas(uid, component.ReleasedGas, component.SuperCriticalMoleAmount);
+ ReleaseGas(uid, component.ReleasedGas, component.SuperCriticalMoleAmount, component.spawnRadius, component.tileCount, component.tempChange);
}
public override void Update(float frameTime)
@@ -41,35 +46,49 @@ public sealed class GasProducerAnomalySystem : EntitySystem
// Yes this is unused code since there are no anomalies that
// release gas passively *yet*, but since I'm here I figured
// I'd save someone some time and just add it for the future
- ReleaseGas(ent, comp.ReleasedGas, comp.PassiveMoleAmount * frameTime);
+ ReleaseGas(ent, comp.ReleasedGas, comp.PassiveMoleAmount * frameTime, comp.spawnRadius, comp.tileCount, comp.tempChange);
}
}
- private void ReleaseGas(EntityUid uid, Gas gas, float amount)
+ private void ReleaseGas(EntityUid uid, Gas gas, float mols, float radius, int count, float temp)
{
var xform = Transform(uid);
- var grid = xform.GridUid;
- var map = xform.MapUid;
- var indices = _xform.GetGridOrMapTilePosition(uid, xform);
- var mixture = _atmosphere.GetTileMixture(grid, map, indices, true);
-
- if (mixture == null)
+ if (!_map.TryGetGrid(xform.GridUid, out var grid))
return;
- mixture.AdjustMoles(gas, amount);
+ var localpos = xform.Coordinates.Position;
+ var tilerefs = grid.GetLocalTilesIntersecting(
+ new Box2(localpos + (-radius, -radius), localpos + (radius, radius))).ToArray();
- if (grid is { })
+ if (tilerefs.Length == 0)
+ return;
+
+ var mixture = _atmosphere.GetTileMixture(xform.GridUid, xform.MapUid, _xform.GetGridOrMapTilePosition(uid, xform), true);
+ if (mixture != null)
{
- foreach (var ind in _atmosphere.GetAdjacentTiles(grid.Value, indices))
- {
- var mix = _atmosphere.GetTileMixture(grid, map, ind, true);
+ mixture.AdjustMoles(gas, mols);
+ mixture.Temperature += temp;
+ }
+
+ if (count == 0)
+ return;
- if (mix is not { })
- continue;
+ _random.Shuffle(tilerefs);
+ var amountCounter = 0;
+ foreach (var tileref in tilerefs)
+ {
+ var mix = _atmosphere.GetTileMixture(xform.GridUid, xform.MapUid, tileref.GridIndices, true);
+ amountCounter++;
+ if (mix is not { })
+ continue;
- mix.AdjustMoles(gas, amount);
- }
+ mix.AdjustMoles(gas, mols);
+ mix.Temperature += temp;
+
+ if (amountCounter >= count)
+ return;
}
}
}
+
diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/behonker.yml b/Resources/Prototypes/Entities/Mobs/NPCs/behonker.yml
index ef7882f8d6..bc6d983e3a 100644
--- a/Resources/Prototypes/Entities/Mobs/NPCs/behonker.yml
+++ b/Resources/Prototypes/Entities/Mobs/NPCs/behonker.yml
@@ -111,6 +111,7 @@
- type: GasProducerAnomaly
releasedGas: 3
releaseOnMaxSeverity: true
+ spawnRadius: 0
- type: entity
name: behonker
@@ -153,3 +154,4 @@
- type: GasProducerAnomaly
releasedGas: 8 # Frezon. Please replace if there is a better way to specify this
releaseOnMaxSeverity: true
+ spawnRadius: 0
diff --git a/Resources/Prototypes/Entities/Structures/Specific/anomalies.yml b/Resources/Prototypes/Entities/Structures/Specific/anomalies.yml
index 93b65691d7..5a368044b3 100644
--- a/Resources/Prototypes/Entities/Structures/Specific/anomalies.yml
+++ b/Resources/Prototypes/Entities/Structures/Specific/anomalies.yml
@@ -72,6 +72,9 @@
- type: GasProducerAnomaly
releasedGas: 3
releaseOnMaxSeverity: true
+ spawnRadius: 3
+ tileCount: 5
+ tempChange: 550
- type: entity
id: AnomalyGravity
@@ -227,3 +230,4 @@
- type: GasProducerAnomaly
releasedGas: 8 # Frezon. Please replace if there is a better way to specify this
releaseOnMaxSeverity: true
+ spawnRadius: 0