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()
{
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)
continue;
active.AudioStream?.Stop();

View File

@@ -27,41 +27,45 @@ public sealed partial class AnomalySystem
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)
continue;
_ui.TryCloseAll(component.Owner, AnomalyScannerUiKey.Key);
_ui.TryCloseAll(uid, AnomalyScannerUiKey.Key);
}
}
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)
continue;
UpdateScannerUi(component.Owner, component);
UpdateScannerUi(uid, component);
}
}
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)
continue;
UpdateScannerUi(component.Owner, component);
UpdateScannerUi(uid, component);
}
}
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)
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)
{
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)
continue;
@@ -118,9 +117,9 @@ public sealed partial class AnomalySystem
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)
continue;
@@ -171,9 +170,9 @@ public sealed partial class AnomalySystem
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)
continue;

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
using System.Threading;
using Content.Shared.Anomaly;
using Robust.Shared.Audio;
namespace Content.Server.Anomaly.Components;
@@ -7,7 +7,7 @@ namespace Content.Server.Anomaly.Components;
/// This is used for scanning anomalies and
/// displaying information about them in the ui
/// </summary>
[RegisterComponent]
[RegisterComponent, Access(typeof(SharedAnomalySystem))]
public sealed class AnomalyScannerComponent : Component
{
/// <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.Serialization.TypeSerializers.Implementations.Custom;
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
/// the anomaly's stability and severity.
/// </summary>
[RegisterComponent]
[RegisterComponent, Access(typeof(SharedAnomalySystem))]
public sealed class AnomalyVesselComponent : Component
{
/// <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;
namespace Content.Server.Anomaly.Components;
[RegisterComponent]
[RegisterComponent, Access(typeof(SharedAnomalySystem))]
public sealed class GeneratingAnomalyGeneratorComponent : Component
{
/// <summary>

View File

@@ -49,7 +49,7 @@ public sealed class PyroclasticAnomalySystem : EntitySystem
{
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 { })
continue;
@@ -65,10 +65,9 @@ public sealed class PyroclasticAnomalySystem : EntitySystem
{
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 map = xform.MapUid;
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
/// </summary>
[RegisterComponent, NetworkedComponent]
[RegisterComponent, NetworkedComponent, Access(typeof(SharedAnomalySystem))]
public sealed class AnomalyComponent : Component
{
/// <summary>

View File

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

View File

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

View File

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

View File

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

View File

@@ -312,10 +312,9 @@ public abstract class SharedAnomalySystem : EntitySystem
{
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,
// update it every second to start killing it slowly.
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)
{
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)
continue;
DoAnomalySupercriticalEvent(ent, anom);