- fix: remove old deathgasps
This commit is contained in:
@@ -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<EntityUid, EntityUid> _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)
|
||||
|
||||
Reference in New Issue
Block a user