diff --git a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs index ef949d09fc..52a5881083 100644 --- a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs @@ -268,21 +268,16 @@ public sealed class TraitorRuleSystem : GameRuleSystem _roleSystem.MindAddRole(mindId, new TraitorRoleComponent { PrototypeId = traitorRule.TraitorPrototypeId - }); - // Assign briefing + }, mind); + // Assign briefing and greeting sound _roleSystem.MindAddRole(mindId, new RoleBriefingComponent { Briefing = briefing - }); + }, mind); + _roleSystem.MindPlaySound(mindId, traitorRule.GreetSoundNotification, mind); SendTraitorBriefing(mindId, traitorRule.Codewords, code); traitorRule.TraitorMinds.Add(mindId); - if (_mindSystem.TryGetSession(mindId, out var session)) - { - // Notificate player about new role assignment - _audioSystem.PlayGlobal(traitorRule.GreetSoundNotification, session); - } - // Change the faction _npcFaction.RemoveFaction(entity, "NanoTrasen", false); _npcFaction.AddFaction(entity, "Syndicate"); diff --git a/Content.Server/Ninja/Systems/SpaceNinjaSystem.cs b/Content.Server/Ninja/Systems/SpaceNinjaSystem.cs index 6de2d7dee0..a5b78570db 100644 --- a/Content.Server/Ninja/Systems/SpaceNinjaSystem.cs +++ b/Content.Server/Ninja/Systems/SpaceNinjaSystem.cs @@ -167,6 +167,7 @@ public sealed class SpaceNinjaSystem : SharedSpaceNinjaSystem PrototypeId = "SpaceNinja" }; _role.MindAddRole(mindId, role, mind); + _role.MindPlaySound(mindId, config.GreetingSound, mind); // choose spider charge detonation point var warps = new List(); @@ -179,9 +180,7 @@ public sealed class SpaceNinjaSystem : SharedSpaceNinjaSystem if (warps.Count > 0) role.SpiderChargeTarget = _random.Pick(warps); - var session = mind.Session; - _audio.PlayGlobal(config.GreetingSound, Filter.Empty().AddPlayer(session), false, AudioParams.Default); - _chatMan.DispatchServerMessage(session, Loc.GetString("ninja-role-greeting")); + _chatMan.DispatchServerMessage(mind.Session, Loc.GetString("ninja-role-greeting")); } // TODO: PowerCellDraw, modify when cloak enabled diff --git a/Content.Shared/Roles/SharedRoleSystem.cs b/Content.Shared/Roles/SharedRoleSystem.cs index 9ba625305c..ae49289eb8 100644 --- a/Content.Shared/Roles/SharedRoleSystem.cs +++ b/Content.Shared/Roles/SharedRoleSystem.cs @@ -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)); } + + /// + /// Play a sound for the mind, if it has a session attached. + /// Use this for role greeting sounds. + /// + public void MindPlaySound(EntityUid mindId, SoundSpecifier? sound, MindComponent? mind = null) + { + if (Resolve(mindId, ref mind) && mind.Session != null) + _audio.PlayGlobal(sound, mind.Session); + } }