Add MindPlaySound to role system (#21460)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-11-14 12:52:40 +00:00
committed by GitHub
parent aa704eee81
commit 318d843b80
3 changed files with 18 additions and 12 deletions

View File

@@ -2,6 +2,7 @@
using Content.Shared.Database;
using Content.Shared.Mind;
using Content.Shared.Roles.Jobs;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
namespace Content.Shared.Roles;
@@ -10,6 +11,7 @@ public abstract class SharedRoleSystem : EntitySystem
{
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly IPrototypeManager _prototypes = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedMindSystem _minds = default!;
// TODO please lord make role entities
@@ -153,4 +155,14 @@ public abstract class SharedRoleSystem : EntitySystem
{
return _antagTypes.Contains(typeof(T));
}
/// <summary>
/// Play a sound for the mind, if it has a session attached.
/// Use this for role greeting sounds.
/// </summary>
public void MindPlaySound(EntityUid mindId, SoundSpecifier? sound, MindComponent? mind = null)
{
if (Resolve(mindId, ref mind) && mind.Session != null)
_audio.PlayGlobal(sound, mind.Session);
}
}