- fix: remove old deathgasps
This commit is contained in:
@@ -1,17 +1,12 @@
|
|||||||
using Content.Server.Chat.Systems;
|
using Content.Shared.Mobs;
|
||||||
using Content.Shared.Humanoid;
|
|
||||||
using Content.Shared.Mobs;
|
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Random;
|
|
||||||
|
|
||||||
namespace Content.Server._White.Other.DeathGasps;
|
namespace Content.Server._White.Other.DeathGasps;
|
||||||
|
|
||||||
public sealed class OnDeath : EntitySystem
|
public sealed class OnDeath : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly ChatSystem _chat = default!;
|
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -23,12 +18,6 @@ public sealed class OnDeath : EntitySystem
|
|||||||
private readonly Dictionary<EntityUid, EntityUid> _playingStreams = new();
|
private readonly Dictionary<EntityUid, EntityUid> _playingStreams = new();
|
||||||
private static readonly SoundSpecifier DeathSounds = new SoundCollectionSpecifier("deathSounds");
|
private static readonly SoundSpecifier DeathSounds = new SoundCollectionSpecifier("deathSounds");
|
||||||
private static readonly SoundSpecifier HeartSounds = new SoundCollectionSpecifier("heartSounds");
|
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)
|
private void HandleDeathEvent(EntityUid uid, DeathGaspsComponent component, MobStateChangedEvent args)
|
||||||
{
|
{
|
||||||
@@ -46,15 +35,11 @@ public sealed class OnDeath : EntitySystem
|
|||||||
break;
|
break;
|
||||||
case MobState.Dead:
|
case MobState.Dead:
|
||||||
StopPlayingStream(uid);
|
StopPlayingStream(uid);
|
||||||
var deathGaspMessage = SelectRandomDeathGaspMessage();
|
|
||||||
var localizedMessage = LocalizeDeathGaspMessage(deathGaspMessage);
|
|
||||||
SendDeathGaspMessage(uid, localizedMessage);
|
|
||||||
PlayDeathSound(uid);
|
PlayDeathSound(uid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void PlayPlayingStream(EntityUid uid)
|
private void PlayPlayingStream(EntityUid uid)
|
||||||
{
|
{
|
||||||
if (_playingStreams.TryGetValue(uid, out var currentStream))
|
if (_playingStreams.TryGetValue(uid, out var currentStream))
|
||||||
@@ -63,34 +48,17 @@ public sealed class OnDeath : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
var newStream = _audio.PlayEntity(HeartSounds, uid, uid, AudioParams.Default.WithLoop(true));
|
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)
|
private void StopPlayingStream(EntityUid uid)
|
||||||
{
|
{
|
||||||
if (_playingStreams.TryGetValue(uid, out var currentStream))
|
if (!_playingStreams.TryGetValue(uid, out var currentStream))
|
||||||
{
|
return;
|
||||||
|
|
||||||
_audio.Stop(currentStream);
|
_audio.Stop(currentStream);
|
||||||
_playingStreams.Remove(uid);
|
_playingStreams.Remove(uid);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PlayDeathSound(EntityUid uid)
|
private void PlayDeathSound(EntityUid uid)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user