From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Tue, 8 Apr 2025 09:11:32 +0000 (-0400) Subject: Allow sound to play at the start of anomaly supercritical animation (#36260) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=716c0ef51f761b512c5297894a3a5a8fdc36d294;p=space-station-14.git Allow sound to play at the start of anomaly supercritical animation (#36260) * Add datafield to AnomalyComponent to play a sound when an anomaly enters supercriticality * use Entity pattern * use implicit default for nullable * don't forget to resolve the AnomalyComponent... * Add comment for StartSupercriticalEvent "ent" parameter * use implicit casts from Entity to EntityUid * StartSupercriticalEvent requires AnomalyComponent to resolve --- diff --git a/Content.Server/Anomaly/AnomalySystem.Commands.cs b/Content.Server/Anomaly/AnomalySystem.Commands.cs index b1a7c44439..8b8206490d 100644 --- a/Content.Server/Anomaly/AnomalySystem.Commands.cs +++ b/Content.Server/Anomaly/AnomalySystem.Commands.cs @@ -44,10 +44,10 @@ public sealed partial class AnomalySystem if (!NetEntity.TryParse(args[0], out var uidNet) || !TryGetEntity(uidNet, out var uid)) return; - if (!HasComp(uid)) + if (!TryComp(uid, out var anomaly)) return; - StartSupercriticalEvent(uid.Value); + StartSupercriticalEvent((uid.Value, anomaly)); } private CompletionResult GetAnomalyCompletion(IConsoleShell shell, string[] args) diff --git a/Content.Shared/Anomaly/Components/AnomalyComponent.cs b/Content.Shared/Anomaly/Components/AnomalyComponent.cs index e6228b5fb0..f58f9f1d07 100644 --- a/Content.Shared/Anomaly/Components/AnomalyComponent.cs +++ b/Content.Shared/Anomaly/Components/AnomalyComponent.cs @@ -129,6 +129,12 @@ public sealed partial class AnomalyComponent : Component /// [DataField] public SoundSpecifier? SupercriticalSound = new SoundCollectionSpecifier("Explosion"); + + /// + /// The sound plays at the start of the animation when an anomaly goes supercritical + /// + [DataField] + public SoundSpecifier? SupercriticalSoundAtAnimationStart; #endregion /// diff --git a/Content.Shared/Anomaly/SharedAnomalySystem.cs b/Content.Shared/Anomaly/SharedAnomalySystem.cs index f2afbe2f51..30a7cb04d0 100644 --- a/Content.Shared/Anomaly/SharedAnomalySystem.cs +++ b/Content.Shared/Anomaly/SharedAnomalySystem.cs @@ -116,21 +116,26 @@ public abstract class SharedAnomalySystem : EntitySystem /// /// Begins the animation for going supercritical /// - /// - public void StartSupercriticalEvent(EntityUid uid) + /// Entity to go supercritical + public void StartSupercriticalEvent(Entity ent) { // don't restart it if it's already begun - if (HasComp(uid)) + if (HasComp(ent)) + return; + + if(!Resolve(ent, ref ent.Comp)) return; - AdminLog.Add(LogType.Anomaly, LogImpact.High, $"Anomaly {ToPrettyString(uid)} began to go supercritical."); + AdminLog.Add(LogType.Anomaly, LogImpact.High, $"Anomaly {ToPrettyString(ent.Owner)} began to go supercritical."); if (_net.IsServer) - Log.Info($"Anomaly is going supercritical. Entity: {ToPrettyString(uid)}"); + Log.Info($"Anomaly is going supercritical. Entity: {ToPrettyString(ent.Owner)}"); + + Audio.PlayPvs(ent.Comp.SupercriticalSoundAtAnimationStart, Transform(ent).Coordinates); - var super = AddComp(uid); + var super = AddComp(ent); super.EndTime = Timing.CurTime + super.SupercriticalDuration; - Appearance.SetData(uid, AnomalyVisuals.Supercritical, true); - Dirty(uid, super); + Appearance.SetData(ent, AnomalyVisuals.Supercritical, true); + Dirty(ent, super); } /// @@ -240,7 +245,7 @@ public abstract class SharedAnomalySystem : EntitySystem var newVal = component.Severity + change; if (newVal >= 1) - StartSupercriticalEvent(uid); + StartSupercriticalEvent((uid, component)); component.Severity = Math.Clamp(newVal, 0, 1); Dirty(uid, component);