Pyroclastic Anomaly Supercrit Buff (#17806)

* Added random gas, fixed ice anom, added temperature field.

* Revert "Added random gas, fixed ice anom, added temperature field."

This reverts commit ae5eade86d84d6b1341b7b76754b6f0007dbf3ca.

* I pushed master. Oops. Fixed now.

* Fixed behonker, fixed TempChange.

* Fixed tempchange.
This commit is contained in:
LankLTE
2023-07-03 14:36:22 -07:00
committed by GitHub
parent 85f5507ce9
commit e9665f2a44
4 changed files with 62 additions and 19 deletions

View File

@@ -3,7 +3,7 @@ using Content.Shared.Atmos;
namespace Content.Server.Anomaly.Components; namespace Content.Server.Anomaly.Components;
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent]
public sealed class GasProducerAnomalyComponent : Component public sealed class GasProducerAnomalyComponent : Component
@@ -37,4 +37,22 @@ public sealed class GasProducerAnomalyComponent : Component
/// </summary> /// </summary>
[DataField("passiveMoleAmount")] [DataField("passiveMoleAmount")]
public float PassiveMoleAmount = 1f; public float PassiveMoleAmount = 1f;
/// <summary>
/// The radius of random gas spawns.
/// </summary>
[DataField("spawnRadius", required: true)]
public float spawnRadius = 3;
/// <summary>
/// The number of tiles which will be modified.
/// </summary>
[DataField("tileCount")]
public int tileCount = 1;
/// <summary>
/// The the amount the tempurature should be modified by (negative for decreasing temp)
/// </summary>
[DataField("tempChange")]
public float tempChange = 0;
} }

View File

@@ -3,6 +3,9 @@ using Content.Server.Anomaly.Components;
using Content.Shared.Anomaly.Components; using Content.Shared.Anomaly.Components;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Random;
using System.Linq;
namespace Content.Server.Anomaly.Effects; namespace Content.Server.Anomaly.Effects;
@@ -13,6 +16,8 @@ public sealed class GasProducerAnomalySystem : EntitySystem
{ {
[Dependency] private readonly AtmosphereSystem _atmosphere = default!; [Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly TransformSystem _xform = default!; [Dependency] private readonly TransformSystem _xform = default!;
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -25,7 +30,7 @@ public sealed class GasProducerAnomalySystem : EntitySystem
if (!component.ReleaseOnMaxSeverity) if (!component.ReleaseOnMaxSeverity)
return; 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) 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 // Yes this is unused code since there are no anomalies that
// release gas passively *yet*, but since I'm here I figured // release gas passively *yet*, but since I'm here I figured
// I'd save someone some time and just add it for the future // 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 xform = Transform(uid);
var grid = xform.GridUid;
var map = xform.MapUid;
var indices = _xform.GetGridOrMapTilePosition(uid, xform); if (!_map.TryGetGrid(xform.GridUid, out var grid))
var mixture = _atmosphere.GetTileMixture(grid, map, indices, true);
if (mixture == null)
return; 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)) mixture.AdjustMoles(gas, mols);
{ mixture.Temperature += temp;
var mix = _atmosphere.GetTileMixture(grid, map, ind, true); }
if (count == 0)
return;
if (mix is not { }) _random.Shuffle(tilerefs);
continue; 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;
} }
} }
} }

View File

@@ -111,6 +111,7 @@
- type: GasProducerAnomaly - type: GasProducerAnomaly
releasedGas: 3 releasedGas: 3
releaseOnMaxSeverity: true releaseOnMaxSeverity: true
spawnRadius: 0
- type: entity - type: entity
name: behonker name: behonker
@@ -153,3 +154,4 @@
- type: GasProducerAnomaly - type: GasProducerAnomaly
releasedGas: 8 # Frezon. Please replace if there is a better way to specify this releasedGas: 8 # Frezon. Please replace if there is a better way to specify this
releaseOnMaxSeverity: true releaseOnMaxSeverity: true
spawnRadius: 0

View File

@@ -72,6 +72,9 @@
- type: GasProducerAnomaly - type: GasProducerAnomaly
releasedGas: 3 releasedGas: 3
releaseOnMaxSeverity: true releaseOnMaxSeverity: true
spawnRadius: 3
tileCount: 5
tempChange: 550
- type: entity - type: entity
id: AnomalyGravity id: AnomalyGravity
@@ -227,3 +230,4 @@
- type: GasProducerAnomaly - type: GasProducerAnomaly
releasedGas: 8 # Frezon. Please replace if there is a better way to specify this releasedGas: 8 # Frezon. Please replace if there is a better way to specify this
releaseOnMaxSeverity: true releaseOnMaxSeverity: true
spawnRadius: 0