Files
OldThink/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactPressureTriggerSystem.cs
Jake Huxell 59e46aab93 Reduced Warning Count By 130 For Full Rebuilds (#26518)
* remove deprecated entity coordinate extension functions. Reduces warning count by approximately 50

* final toCoords Removed

* Remove all unused variables and dead code paths

* remove always true variable, should be a cvar or something instead

* remove superfluous variables from tests
2024-03-29 16:28:16 +11:00

37 lines
1.3 KiB
C#

using Content.Server.Atmos.EntitySystems;
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;
/// <summary>
/// This handles activation upon certain pressure thresholds.
/// </summary>
public sealed class ArtifactPressureTriggerSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly ArtifactSystem _artifactSystem = default!;
public override void Update(float frameTime)
{
base.Update(frameTime);
List<Entity<ArtifactComponent>> toUpdate = new();
var query = EntityQueryEnumerator<ArtifactPressureTriggerComponent, ArtifactComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var trigger, out var artifact, out var transform))
{
var environment = _atmosphereSystem.GetTileMixture((uid, transform));
if (environment == null)
continue;
var pressure = environment.Pressure;
if (pressure >= trigger.MaxPressureThreshold || pressure <= trigger.MinPressureThreshold)
toUpdate.Add((uid, artifact));
}
foreach (var a in toUpdate)
{
_artifactSystem.TryActivateArtifact(a, null, a);
}
}
}