Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Add more anomaly logs (space-wizards#16178)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroJr authored and Vordenburg committed May 8, 2023
1 parent 809ccd6 commit 5cdcafd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Content.Shared/Anomaly/SharedAnomalySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public abstract class SharedAnomalySystem : EntitySystem
[Dependency] protected readonly SharedPopupSystem Popup = default!;
[Dependency] private readonly SharedGlimmerSystem _glimmer = default!;

private ISawmill _sawmill = default!;

public override void Initialize()
{
base.Initialize();
Expand All @@ -40,6 +42,8 @@ public override void Initialize()
SubscribeLocalEvent<AnomalyComponent, EntityUnpausedEvent>(OnAnomalyUnpause);
SubscribeLocalEvent<AnomalyPulsingComponent, EntityUnpausedEvent>(OnPulsingUnpause);
SubscribeLocalEvent<AnomalySupercriticalComponent, EntityUnpausedEvent>(OnSupercriticalUnpause);

_sawmill = Logger.GetSawmill("anomaly");
}

private void OnAnomalyGetState(EntityUid uid, AnomalyComponent component, ref ComponentGetState args)
Expand Down Expand Up @@ -128,6 +132,8 @@ public void DoAnomalyPulse(EntityUid uid, AnomalyComponent? component = null)
var variation = Random.NextFloat(-component.PulseVariation, component.PulseVariation) + 1;
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 (component.Stability > component.GrowthThreshold)
{
Expand Down Expand Up @@ -161,6 +167,7 @@ public void StartSupercriticalEvent(EntityUid uid)
return;

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);
super.EndTime = Timing.CurTime + super.SupercriticalDuration;
Expand All @@ -185,6 +192,7 @@ public void DoAnomalySupercriticalEvent(EntityUid uid, AnomalyComponent? compone

Audio.PlayPvs(component.SupercriticalSound, uid);

_sawmill.Info($"Raising supercritical event. Entity: {ToPrettyString(uid)}");
var ev = new AnomalySupercriticalEvent();
_glimmer.Glimmer += 100;
RaiseLocalEvent(uid, ref ev);
Expand All @@ -200,14 +208,16 @@ public void DoAnomalySupercriticalEvent(EntityUid uid, AnomalyComponent? compone
/// <param name="supercritical">Whether or not the anomaly ended via supercritical event</param>
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))
return;

var ev = new AnomalyShutdownEvent(uid, supercritical);
RaiseLocalEvent(uid, ref ev, true);

Log.Add(LogType.Anomaly, LogImpact.Extreme, $"Anomaly {ToPrettyString(uid)} went supercritical.");

if (Terminating(uid) || _net.IsClient)
return;
Del(uid);
Expand Down

0 comments on commit 5cdcafd

Please sign in to comment.