From b44f512b862bd91f3e033795c5cfe3fc56adfe4a Mon Sep 17 00:00:00 2001 From: rhailrake <49613070+rhailrake@users.noreply.github.com> Date: Wed, 31 Jan 2024 20:07:06 +0600 Subject: [PATCH] - fix: remove old deathgasps --- .../_White/Other/DeathGasps/OnDeath.cs | 44 +++---------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/Content.Server/_White/Other/DeathGasps/OnDeath.cs b/Content.Server/_White/Other/DeathGasps/OnDeath.cs index 7bd0362414..b283104055 100644 --- a/Content.Server/_White/Other/DeathGasps/OnDeath.cs +++ b/Content.Server/_White/Other/DeathGasps/OnDeath.cs @@ -1,17 +1,12 @@ -using Content.Server.Chat.Systems; -using Content.Shared.Humanoid; -using Content.Shared.Mobs; +using Content.Shared.Mobs; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Player; -using Robust.Shared.Random; namespace Content.Server._White.Other.DeathGasps; public sealed class OnDeath : EntitySystem { - [Dependency] private readonly ChatSystem _chat = default!; - [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; public override void Initialize() @@ -23,12 +18,6 @@ public sealed class OnDeath : EntitySystem private readonly Dictionary _playingStreams = new(); private static readonly SoundSpecifier DeathSounds = new SoundCollectionSpecifier("deathSounds"); private static readonly SoundSpecifier HeartSounds = new SoundCollectionSpecifier("heartSounds"); - private static readonly string[] DeathGaspMessages = - { - "death-gasp-high", - "death-gasp-medium", - "death-gasp-normal" - }; private void HandleDeathEvent(EntityUid uid, DeathGaspsComponent component, MobStateChangedEvent args) { @@ -46,15 +35,11 @@ public sealed class OnDeath : EntitySystem break; case MobState.Dead: StopPlayingStream(uid); - var deathGaspMessage = SelectRandomDeathGaspMessage(); - var localizedMessage = LocalizeDeathGaspMessage(deathGaspMessage); - SendDeathGaspMessage(uid, localizedMessage); PlayDeathSound(uid); break; } } - private void PlayPlayingStream(EntityUid uid) { if (_playingStreams.TryGetValue(uid, out var currentStream)) @@ -63,33 +48,16 @@ public sealed class OnDeath : EntitySystem } var newStream = _audio.PlayEntity(HeartSounds, uid, uid, AudioParams.Default.WithLoop(true)); - if (newStream != null) - _playingStreams[uid] = newStream.Value.Entity; + _playingStreams[uid] = newStream.Value.Entity; } private void StopPlayingStream(EntityUid uid) { - if (_playingStreams.TryGetValue(uid, out var currentStream)) - { - _audio.Stop(currentStream); - _playingStreams.Remove(uid); - } - } + if (!_playingStreams.TryGetValue(uid, out var currentStream)) + return; - private string SelectRandomDeathGaspMessage() - { - return DeathGaspMessages[_random.Next(DeathGaspMessages.Length)]; - } - - private string LocalizeDeathGaspMessage(string message) - { - return Loc.GetString(message); - } - - private void SendDeathGaspMessage(EntityUid uid, string message) - { - _chat.TrySendInGameICMessage(uid, message, InGameICChatType.Emote, ChatTransmitRange.Normal, - ignoreActionBlocker: true); + _audio.Stop(currentStream); + _playingStreams.Remove(uid); } private void PlayDeathSound(EntityUid uid)