Anomaly cleanup (#14781)

This commit is contained in:
Nemanja
2023-03-23 01:53:32 -04:00
committed by GitHub
parent 3a545a171e
commit d5d9046fb6
16 changed files with 46 additions and 47 deletions

View File

@@ -162,10 +162,9 @@ public sealed partial class AnomalySystem
private void UpdateGenerator() private void UpdateGenerator()
{ {
foreach (var (active, gen) in EntityQuery<GeneratingAnomalyGeneratorComponent, AnomalyGeneratorComponent>()) var query = EntityQueryEnumerator<GeneratingAnomalyGeneratorComponent, AnomalyGeneratorComponent>();
while (query.MoveNext(out var ent, out var active, out var gen))
{ {
var ent = active.Owner;
if (Timing.CurTime < active.EndTime) if (Timing.CurTime < active.EndTime)
continue; continue;
active.AudioStream?.Stop(); active.AudioStream?.Stop();

View File

@@ -27,41 +27,45 @@ public sealed partial class AnomalySystem
private void OnScannerAnomalyShutdown(ref AnomalyShutdownEvent args) private void OnScannerAnomalyShutdown(ref AnomalyShutdownEvent args)
{ {
foreach (var component in EntityQuery<AnomalyScannerComponent>()) var query = EntityQueryEnumerator<AnomalyScannerComponent>();
while (query.MoveNext(out var uid, out var component))
{ {
if (component.ScannedAnomaly != args.Anomaly) if (component.ScannedAnomaly != args.Anomaly)
continue; continue;
_ui.TryCloseAll(component.Owner, AnomalyScannerUiKey.Key); _ui.TryCloseAll(uid, AnomalyScannerUiKey.Key);
} }
} }
private void OnScannerAnomalySeverityChanged(ref AnomalySeverityChangedEvent args) private void OnScannerAnomalySeverityChanged(ref AnomalySeverityChangedEvent args)
{ {
foreach (var component in EntityQuery<AnomalyScannerComponent>()) var query = EntityQueryEnumerator<AnomalyScannerComponent>();
while (query.MoveNext(out var uid, out var component))
{ {
if (component.ScannedAnomaly != args.Anomaly) if (component.ScannedAnomaly != args.Anomaly)
continue; continue;
UpdateScannerUi(component.Owner, component); UpdateScannerUi(uid, component);
} }
} }
private void OnScannerAnomalyStabilityChanged(ref AnomalyStabilityChangedEvent args) private void OnScannerAnomalyStabilityChanged(ref AnomalyStabilityChangedEvent args)
{ {
foreach (var component in EntityQuery<AnomalyScannerComponent>()) var query = EntityQueryEnumerator<AnomalyScannerComponent>();
while (query.MoveNext(out var uid, out var component))
{ {
if (component.ScannedAnomaly != args.Anomaly) if (component.ScannedAnomaly != args.Anomaly)
continue; continue;
UpdateScannerUi(component.Owner, component); UpdateScannerUi(uid, component);
} }
} }
private void OnScannerAnomalyHealthChanged(ref AnomalyHealthChangedEvent args) private void OnScannerAnomalyHealthChanged(ref AnomalyHealthChangedEvent args)
{ {
foreach (var component in EntityQuery<AnomalyScannerComponent>()) var query = EntityQueryEnumerator<AnomalyScannerComponent>();
while (query.MoveNext(out var uid, out var component))
{ {
if (component.ScannedAnomaly != args.Anomaly) if (component.ScannedAnomaly != args.Anomaly)
continue; continue;
UpdateScannerUi(component.Owner, component); UpdateScannerUi(uid, component);
} }
} }

View File

@@ -100,10 +100,9 @@ public sealed partial class AnomalySystem
private void OnVesselAnomalyShutdown(ref AnomalyShutdownEvent args) private void OnVesselAnomalyShutdown(ref AnomalyShutdownEvent args)
{ {
foreach (var component in EntityQuery<AnomalyVesselComponent>()) var query = EntityQueryEnumerator<AnomalyVesselComponent>();
while (query.MoveNext(out var ent, out var component))
{ {
var ent = component.Owner;
if (args.Anomaly != component.Anomaly) if (args.Anomaly != component.Anomaly)
continue; continue;
@@ -118,9 +117,9 @@ public sealed partial class AnomalySystem
private void OnVesselAnomalyStabilityChanged(ref AnomalyStabilityChangedEvent args) private void OnVesselAnomalyStabilityChanged(ref AnomalyStabilityChangedEvent args)
{ {
foreach (var component in EntityQuery<AnomalyVesselComponent>()) var query = EntityQueryEnumerator<AnomalyVesselComponent>();
while (query.MoveNext(out var ent, out var component))
{ {
var ent = component.Owner;
if (args.Anomaly != component.Anomaly) if (args.Anomaly != component.Anomaly)
continue; continue;
@@ -171,9 +170,9 @@ public sealed partial class AnomalySystem
private void UpdateVessels() private void UpdateVessels()
{ {
foreach (var vessel in EntityQuery<AnomalyVesselComponent>()) var query = EntityQueryEnumerator<AnomalyVesselComponent>();
while (query.MoveNext(out var vesselEnt, out var vessel))
{ {
var vesselEnt = vessel.Owner;
if (vessel.Anomaly is not { } anomUid) if (vessel.Anomaly is not { } anomUid)
continue; continue;

View File

@@ -7,7 +7,6 @@ using Content.Server.Materials;
using Content.Server.Radio.EntitySystems; using Content.Server.Radio.EntitySystems;
using Content.Shared.Anomaly; using Content.Shared.Anomaly;
using Content.Shared.Anomaly.Components; using Content.Shared.Anomaly.Components;
using Content.Shared.DoAfter;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Events;

View File

@@ -5,7 +5,7 @@ namespace Content.Server.Anomaly.Components;
/// <summary> /// <summary>
/// This is used for projectiles which affect anomalies through colliding with them. /// This is used for projectiles which affect anomalies through colliding with them.
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent, Access(typeof(SharedAnomalySystem))]
public sealed class AnomalousParticleComponent : Component public sealed class AnomalousParticleComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -1,4 +1,5 @@
using Content.Shared.Materials; using Content.Shared.Anomaly;
using Content.Shared.Materials;
using Content.Shared.Radio; using Content.Shared.Radio;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -11,7 +12,7 @@ namespace Content.Server.Anomaly.Components;
/// This is used for a machine that is able to generate /// This is used for a machine that is able to generate
/// anomalies randomly on the station. /// anomalies randomly on the station.
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent, Access(typeof(SharedAnomalySystem))]
public sealed class AnomalyGeneratorComponent : Component public sealed class AnomalyGeneratorComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -1,4 +1,4 @@
using System.Threading; using Content.Shared.Anomaly;
using Robust.Shared.Audio; using Robust.Shared.Audio;
namespace Content.Server.Anomaly.Components; namespace Content.Server.Anomaly.Components;
@@ -7,7 +7,7 @@ namespace Content.Server.Anomaly.Components;
/// This is used for scanning anomalies and /// This is used for scanning anomalies and
/// displaying information about them in the ui /// displaying information about them in the ui
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent, Access(typeof(SharedAnomalySystem))]
public sealed class AnomalyScannerComponent : Component public sealed class AnomalyScannerComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -1,4 +1,5 @@
using Content.Shared.Construction.Prototypes; using Content.Shared.Anomaly;
using Content.Shared.Construction.Prototypes;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
@@ -11,7 +12,7 @@ namespace Content.Server.Anomaly.Components;
/// they generate points for the selected server based on /// they generate points for the selected server based on
/// the anomaly's stability and severity. /// the anomaly's stability and severity.
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent, Access(typeof(SharedAnomalySystem))]
public sealed class AnomalyVesselComponent : Component public sealed class AnomalyVesselComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -1,9 +1,10 @@
using Robust.Shared.Audio; using Content.Shared.Anomaly;
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.Anomaly.Components; namespace Content.Server.Anomaly.Components;
[RegisterComponent] [RegisterComponent, Access(typeof(SharedAnomalySystem))]
public sealed class GeneratingAnomalyGeneratorComponent : Component public sealed class GeneratingAnomalyGeneratorComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -49,7 +49,7 @@ public sealed class PyroclasticAnomalySystem : EntitySystem
{ {
foreach (var ind in _atmosphere.GetAdjacentTiles(grid.Value, indices)) foreach (var ind in _atmosphere.GetAdjacentTiles(grid.Value, indices))
{ {
var mix = _atmosphere.GetTileMixture(grid, map, indices, true); var mix = _atmosphere.GetTileMixture(grid, map, ind, true);
if (mix is not { }) if (mix is not { })
continue; continue;
@@ -65,10 +65,9 @@ public sealed class PyroclasticAnomalySystem : EntitySystem
{ {
base.Update(frameTime); base.Update(frameTime);
foreach (var (pyro, anom, xform) in EntityQuery<PyroclasticAnomalyComponent, AnomalyComponent, TransformComponent>()) var query = EntityQueryEnumerator<PyroclasticAnomalyComponent, AnomalyComponent, TransformComponent>();
while (query.MoveNext(out var ent, out var pyro, out var anom, out var xform))
{ {
var ent = pyro.Owner;
var grid = xform.GridUid; var grid = xform.GridUid;
var map = xform.MapUid; var map = xform.MapUid;
var indices = _xform.GetGridOrMapTilePosition(ent, xform); var indices = _xform.GetGridOrMapTilePosition(ent, xform);

View File

@@ -13,7 +13,7 @@ namespace Content.Shared.Anomaly.Components;
/// ///
/// Anomalies and their related components were designed here: https://hackmd.io/@ss14-design/r1sQbkJOs /// Anomalies and their related components were designed here: https://hackmd.io/@ss14-design/r1sQbkJOs
/// </summary> /// </summary>
[RegisterComponent, NetworkedComponent] [RegisterComponent, NetworkedComponent, Access(typeof(SharedAnomalySystem))]
public sealed class AnomalyComponent : Component public sealed class AnomalyComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -5,7 +5,7 @@ namespace Content.Shared.Anomaly.Components;
/// <summary> /// <summary>
/// This component tracks anomalies that are currently pulsing /// This component tracks anomalies that are currently pulsing
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent, Access(typeof(SharedAnomalySystem))]
public sealed class AnomalyPulsingComponent : Component public sealed class AnomalyPulsingComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -7,7 +7,7 @@ namespace Content.Shared.Anomaly.Components;
/// <summary> /// <summary>
/// Tracks anomalies going supercritical /// Tracks anomalies going supercritical
/// </summary> /// </summary>
[RegisterComponent, NetworkedComponent] [RegisterComponent, NetworkedComponent, Access(typeof(SharedAnomalySystem))]
public sealed class AnomalySupercriticalComponent : Component public sealed class AnomalySupercriticalComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -3,8 +3,7 @@ using Robust.Shared.GameStates;
namespace Content.Shared.Anomaly.Effects.Components; namespace Content.Shared.Anomaly.Effects.Components;
[RegisterComponent, NetworkedComponent] [RegisterComponent, NetworkedComponent, Access(typeof(BluespaceAnomalySystem))]
[Access(typeof(BluespaceAnomalySystem))]
public sealed class BluespaceAnomalyComponent : Component public sealed class BluespaceAnomalyComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -2,7 +2,7 @@
namespace Content.Shared.Anomaly.Effects.Components; namespace Content.Shared.Anomaly.Effects.Components;
[RegisterComponent, NetworkedComponent] [RegisterComponent, NetworkedComponent, Access(typeof(SharedGravityAnomalySystem))]
public sealed class GravityAnomalyComponent : Component public sealed class GravityAnomalyComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -312,10 +312,9 @@ public abstract class SharedAnomalySystem : EntitySystem
{ {
base.Update(frameTime); base.Update(frameTime);
foreach (var anomaly in EntityQuery<AnomalyComponent>()) var anomalyQuery = EntityQueryEnumerator<AnomalyComponent>();
while (anomalyQuery.MoveNext(out var ent, out var anomaly))
{ {
var ent = anomaly.Owner;
// if the stability is under the death threshold, // if the stability is under the death threshold,
// update it every second to start killing it slowly. // update it every second to start killing it slowly.
if (anomaly.Stability < anomaly.DecayThreshold) if (anomaly.Stability < anomaly.DecayThreshold)
@@ -329,10 +328,9 @@ public abstract class SharedAnomalySystem : EntitySystem
} }
} }
foreach (var pulse in EntityQuery<AnomalyPulsingComponent>()) var pulseQuery = EntityQueryEnumerator<AnomalyPulsingComponent>();
while (pulseQuery.MoveNext(out var ent, out var pulse))
{ {
var ent = pulse.Owner;
if (Timing.CurTime > pulse.EndTime) if (Timing.CurTime > pulse.EndTime)
{ {
Appearance.SetData(ent, AnomalyVisuals.IsPulsing, false); Appearance.SetData(ent, AnomalyVisuals.IsPulsing, false);
@@ -340,10 +338,9 @@ public abstract class SharedAnomalySystem : EntitySystem
} }
} }
foreach (var (super, anom) in EntityQuery<AnomalySupercriticalComponent, AnomalyComponent>()) var supercriticalQuery = EntityQueryEnumerator<AnomalySupercriticalComponent, AnomalyComponent>();
while (supercriticalQuery.MoveNext(out var ent, out var super, out var anom))
{ {
var ent = anom.Owner;
if (Timing.CurTime <= super.EndTime) if (Timing.CurTime <= super.EndTime)
continue; continue;
DoAnomalySupercriticalEvent(ent, anom); DoAnomalySupercriticalEvent(ent, anom);