Add more anomaly logs (#16178)

This commit is contained in:
Leon Friedrich
2023-05-07 05:56:18 +12:00
committed by GitHub
parent f1f28dcc19
commit cebf021a12

View File

@@ -24,6 +24,8 @@ public abstract class SharedAnomalySystem : EntitySystem
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!; [Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
[Dependency] protected readonly SharedPopupSystem Popup = default!; [Dependency] protected readonly SharedPopupSystem Popup = default!;
private ISawmill _sawmill = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -38,6 +40,8 @@ public abstract class SharedAnomalySystem : EntitySystem
SubscribeLocalEvent<AnomalyComponent, EntityUnpausedEvent>(OnAnomalyUnpause); SubscribeLocalEvent<AnomalyComponent, EntityUnpausedEvent>(OnAnomalyUnpause);
SubscribeLocalEvent<AnomalyPulsingComponent, EntityUnpausedEvent>(OnPulsingUnpause); SubscribeLocalEvent<AnomalyPulsingComponent, EntityUnpausedEvent>(OnPulsingUnpause);
SubscribeLocalEvent<AnomalySupercriticalComponent, EntityUnpausedEvent>(OnSupercriticalUnpause); SubscribeLocalEvent<AnomalySupercriticalComponent, EntityUnpausedEvent>(OnSupercriticalUnpause);
_sawmill = Logger.GetSawmill("anomaly");
} }
private void OnAnomalyGetState(EntityUid uid, AnomalyComponent component, ref ComponentGetState args) private void OnAnomalyGetState(EntityUid uid, AnomalyComponent component, ref ComponentGetState args)
@@ -126,6 +130,8 @@ public abstract class SharedAnomalySystem : EntitySystem
var variation = Random.NextFloat(-component.PulseVariation, component.PulseVariation) + 1; var variation = Random.NextFloat(-component.PulseVariation, component.PulseVariation) + 1;
component.NextPulseTime = Timing.CurTime + GetPulseLength(component) * variation; component.NextPulseTime = Timing.CurTime + GetPulseLength(component) * variation;
_sawmill.Info($"Performing anomaly pulse. Entity: {ToPrettyString(uid)}");
// if we are above the growth threshold, then grow before the pulse // if we are above the growth threshold, then grow before the pulse
if (component.Stability > component.GrowthThreshold) if (component.Stability > component.GrowthThreshold)
{ {
@@ -158,6 +164,7 @@ public abstract class SharedAnomalySystem : EntitySystem
return; return;
Log.Add(LogType.Anomaly, LogImpact.High, $"Anomaly {ToPrettyString(uid)} began to go supercritical."); Log.Add(LogType.Anomaly, LogImpact.High, $"Anomaly {ToPrettyString(uid)} began to go supercritical.");
_sawmill.Info($"Anomaly is going supercritical. Entity: {ToPrettyString(uid)}");
var super = EnsureComp<AnomalySupercriticalComponent>(uid); var super = EnsureComp<AnomalySupercriticalComponent>(uid);
super.EndTime = Timing.CurTime + super.SupercriticalDuration; super.EndTime = Timing.CurTime + super.SupercriticalDuration;
@@ -182,6 +189,7 @@ public abstract class SharedAnomalySystem : EntitySystem
Audio.PlayPvs(component.SupercriticalSound, uid); Audio.PlayPvs(component.SupercriticalSound, uid);
_sawmill.Info($"Raising supercritical event. Entity: {ToPrettyString(uid)}");
var ev = new AnomalySupercriticalEvent(); var ev = new AnomalySupercriticalEvent();
RaiseLocalEvent(uid, ref ev); RaiseLocalEvent(uid, ref ev);
@@ -196,14 +204,16 @@ public abstract class SharedAnomalySystem : EntitySystem
/// <param name="supercritical">Whether or not the anomaly ended via supercritical event</param> /// <param name="supercritical">Whether or not the anomaly ended via supercritical event</param>
public void EndAnomaly(EntityUid uid, AnomalyComponent? component = null, bool supercritical = false) public void EndAnomaly(EntityUid uid, AnomalyComponent? component = null, bool supercritical = false)
{ {
// Logging before resolve, in case the anomaly has deleted itself.
_sawmill.Info($"Ending anomaly. Entity: {ToPrettyString(uid)}");
Log.Add(LogType.Anomaly, LogImpact.Extreme, $"Anomaly {ToPrettyString(uid)} went supercritical.");
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
var ev = new AnomalyShutdownEvent(uid, supercritical); var ev = new AnomalyShutdownEvent(uid, supercritical);
RaiseLocalEvent(uid, ref ev, true); RaiseLocalEvent(uid, ref ev, true);
Log.Add(LogType.Anomaly, LogImpact.Extreme, $"Anomaly {ToPrettyString(uid)} went supercritical.");
if (Terminating(uid) || _net.IsClient) if (Terminating(uid) || _net.IsClient)
return; return;
Del(uid); Del(uid);