diff --git a/Content.Server/Silicons/Laws/SiliconLawEui.cs b/Content.Server/Silicons/Laws/SiliconLawEui.cs index d5a5c4f409..9fd639e9b3 100644 --- a/Content.Server/Silicons/Laws/SiliconLawEui.cs +++ b/Content.Server/Silicons/Laws/SiliconLawEui.cs @@ -1,4 +1,4 @@ -using Content.Server.Administration.Managers; +using Content.Server.Administration.Managers; using Content.Server.EUI; using Content.Shared.Administration; using Content.Shared.Eui; @@ -52,8 +52,8 @@ public sealed class SiliconLawEui : BaseEui return; var player = _entityManager.GetEntity(message.Target); - - _siliconLawSystem.SetLaws(message.Laws, player); + if (_entityManager.TryGetComponent(player, out var playerProviderComp)) + _siliconLawSystem.SetLaws(message.Laws, player, playerProviderComp.LawUploadSound); } private bool IsAllowed() diff --git a/Content.Server/Silicons/Laws/SiliconLawSystem.cs b/Content.Server/Silicons/Laws/SiliconLawSystem.cs index 0070beb6ef..9a361132a5 100644 --- a/Content.Server/Silicons/Laws/SiliconLawSystem.cs +++ b/Content.Server/Silicons/Laws/SiliconLawSystem.cs @@ -21,6 +21,8 @@ using Robust.Shared.Containers; using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Toolshed; +using Robust.Shared.Audio; +using Robust.Shared.GameObjects; namespace Content.Server.Silicons.Laws; @@ -113,7 +115,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem component.Lawset = args.Lawset; // gotta tell player to check their laws - NotifyLawsChanged(uid); + NotifyLawsChanged(uid, component.LawUploadSound); // new laws may allow antagonist behaviour so make it clear for admins if (TryComp(uid, out var emag)) @@ -149,14 +151,11 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem return; base.OnGotEmagged(uid, component, ref args); - NotifyLawsChanged(uid); + NotifyLawsChanged(uid, component.EmaggedSound); EnsureEmaggedRole(uid, component); _stunSystem.TryParalyze(uid, component.StunTime, true); - if (!_mind.TryGetMind(uid, out var mindId, out _)) - return; - _roles.MindPlaySound(mindId, component.EmaggedSound); } private void OnEmagMindAdded(EntityUid uid, EmagSiliconLawComponent component, MindAddedMessage args) @@ -237,7 +236,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem return ev.Laws; } - public void NotifyLawsChanged(EntityUid uid) + public void NotifyLawsChanged(EntityUid uid, SoundSpecifier? cue = null) { if (!TryComp(uid, out var actor)) return; @@ -245,6 +244,9 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem var msg = Loc.GetString("laws-update-notify"); var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", msg)); _chatManager.ChatMessageToOne(ChatChannel.Server, msg, wrappedMessage, default, false, actor.PlayerSession.Channel, colorOverride: Color.Red); + + if (cue != null && _mind.TryGetMind(uid, out var mindId, out _)) + _roles.MindPlaySound(mindId, cue); } /// @@ -269,7 +271,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem /// /// Set the laws of a silicon entity while notifying the player. /// - public void SetLaws(List newLaws, EntityUid target) + public void SetLaws(List newLaws, EntityUid target, SoundSpecifier? cue = null) { if (!TryComp(target, out var component)) return; @@ -278,7 +280,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem component.Lawset = new SiliconLawset(); component.Lawset.Laws = newLaws; - NotifyLawsChanged(target); + NotifyLawsChanged(target, cue); } protected override void OnUpdaterInsert(Entity ent, ref EntInsertedIntoContainerMessage args) @@ -292,9 +294,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem while (query.MoveNext(out var update)) { - SetLaws(lawset, update); - if (provider.LawUploadSound != null && _mind.TryGetMind(update, out var mindId, out _)) - _roles.MindPlaySound(mindId, provider.LawUploadSound); + SetLaws(lawset, update, provider.LawUploadSound); } } } diff --git a/Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs b/Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs index 1c54938b8a..4885bd0265 100644 --- a/Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs +++ b/Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs @@ -24,7 +24,7 @@ public sealed partial class SiliconLawProviderComponent : Component /// /// The sound that plays for the Silicon player - /// when the particular lawboard has been inserted. + /// when the law change is processed for the provider. /// [DataField] public SoundSpecifier? LawUploadSound = new SoundPathSpecifier("/Audio/Misc/cryo_warning.ogg");