Files
wwdpublic/Content.Server/Speech/Muting/MutingSystem.cs
VMSolidus 7892a4cf67 Remove Default Scream Action (#1589)
# Description

This PR adds a new server configuration that disables the special Scream
Action that all players spawn with. It's stupid, it's NRP. And you can
still scream with the emote or emote wheel. If the config is set to
false at roundstart, the Scream action simply won't spawn.

# Changelog

🆑
- tweak: The "Scream Action" no longer appears by default. It may be set
in your server's configuration to spawn or not.

(cherry picked from commit 48a3233ee0ad7ebce93821ff3cb1162558d01288)
2025-01-20 21:08:33 +03:00

71 lines
2.7 KiB
C#

using Content.Server.Abilities.Mime;
using Content.Server.Chat.Systems;
using Content.Server.Language;
using Content.Server.Popups;
using Content.Server.Speech.Components;
using Content.Server.Speech.EntitySystems;
using Content.Shared.CCVar;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Puppet;
using Content.Shared.Speech;
using Content.Shared.Speech.Muting;
using Robust.Shared.Configuration;
namespace Content.Server.Speech.Muting
{
public sealed class MutingSystem : EntitySystem
{
[Dependency] private readonly LanguageSystem _languages = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MutedComponent, SpeakAttemptEvent>(OnSpeakAttempt);
SubscribeLocalEvent<MutedComponent, EmoteEvent>(OnEmote, before: new[] { typeof(VocalSystem) });
SubscribeLocalEvent<MutedComponent, ScreamActionEvent>(OnScreamAction, before: new[] { typeof(VocalSystem) });
}
private void OnEmote(EntityUid uid, MutedComponent component, ref EmoteEvent args)
{
if (args.Handled)
return;
//still leaves the text so it looks like they are pantomiming a laugh
if (args.Emote.Category.HasFlag(EmoteCategory.Vocal))
args.Handled = true;
}
private void OnScreamAction(EntityUid uid, MutedComponent component, ScreamActionEvent args)
{
if (args.Handled || !_config.GetCVar(CCVars.AllowScreamAction))
return;
if (HasComp<MimePowersComponent>(uid))
_popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid);
else
_popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid);
args.Handled = true;
}
private void OnSpeakAttempt(EntityUid uid, MutedComponent component, SpeakAttemptEvent args)
{
var language = _languages.GetLanguage(uid);
if (!language.SpeechOverride.RequireSpeech)
return; // Cannot mute if there's no speech involved
if (HasComp<MimePowersComponent>(uid))
_popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid);
else if (HasComp<VentriloquistPuppetComponent>(uid))
_popupSystem.PopupEntity(Loc.GetString("ventriloquist-puppet-cant-speak"), uid, uid);
else
_popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid);
args.Cancel();
}
}
}