From 6403503938b0835c49c3fdd6f4552551de5419de Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Sat, 9 Mar 2024 23:16:55 -0800 Subject: [PATCH] don't add the scream action --- .../Speech/Components/VocalComponent.cs | 6 +++++ .../Speech/EntitySystems/VocalSystem.cs | 22 +++++++++++++++++++ Content.Server/Speech/Muting/MutingSystem.cs | 14 ++++++++++++ Content.Shared/Speech/ScreamActionEvent.cs | 7 ++++++ Resources/Prototypes/Actions/types.yml | 12 ++++++++++ Resources/Prototypes/Catalog/catalog.yml | 2 +- 6 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Content.Shared/Speech/ScreamActionEvent.cs diff --git a/Content.Server/Speech/Components/VocalComponent.cs b/Content.Server/Speech/Components/VocalComponent.cs index e4b72e140a..029d638a66 100644 --- a/Content.Server/Speech/Components/VocalComponent.cs +++ b/Content.Server/Speech/Components/VocalComponent.cs @@ -31,6 +31,12 @@ public sealed partial class VocalComponent : Component [DataField("wilhelmProbability")] public float WilhelmProbability = 0.0002f; + [DataField("screamAction", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string ScreamAction = "ActionScream"; + + [DataField("screamActionEntity")] + public EntityUid? ScreamActionEntity; + /// /// Currently loaded emote sounds prototype, based on entity sex. /// Null if no valid prototype for entity sex was found. diff --git a/Content.Server/Speech/EntitySystems/VocalSystem.cs b/Content.Server/Speech/EntitySystems/VocalSystem.cs index bf47c6cd96..9ce12bed95 100644 --- a/Content.Server/Speech/EntitySystems/VocalSystem.cs +++ b/Content.Server/Speech/EntitySystems/VocalSystem.cs @@ -24,15 +24,28 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnMapInit); + SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnSexChanged); SubscribeLocalEvent(OnEmote); + SubscribeLocalEvent(OnScreamAction); } private void OnMapInit(EntityUid uid, VocalComponent component, MapInitEvent args) { + // try to add scream action when vocal comp added + // _actions.AddAction(uid, ref component.ScreamActionEntity, component.ScreamAction); // Parkstation-RemoveScreamAction LoadSounds(uid, component); } + private void OnShutdown(EntityUid uid, VocalComponent component, ComponentShutdown args) + { + // remove scream action when component removed + if (component.ScreamActionEntity != null) + { + _actions.RemoveAction(uid, component.ScreamActionEntity); + } + } + private void OnSexChanged(EntityUid uid, VocalComponent component, SexChangedEvent args) { LoadSounds(uid, component); @@ -54,6 +67,15 @@ private void OnEmote(EntityUid uid, VocalComponent component, ref EmoteEvent arg args.Handled = _chat.TryPlayEmoteSound(uid, component.EmoteSounds, args.Emote); } + private void OnScreamAction(EntityUid uid, VocalComponent component, ScreamActionEvent args) + { + if (args.Handled) + return; + + _chat.TryEmoteWithChat(uid, component.ScreamId); + args.Handled = true; + } + private bool TryPlayScreamSound(EntityUid uid, VocalComponent component) { if (_random.Prob(component.WilhelmProbability)) diff --git a/Content.Server/Speech/Muting/MutingSystem.cs b/Content.Server/Speech/Muting/MutingSystem.cs index e003e49931..b743d9eda8 100644 --- a/Content.Server/Speech/Muting/MutingSystem.cs +++ b/Content.Server/Speech/Muting/MutingSystem.cs @@ -17,6 +17,7 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnSpeakAttempt); SubscribeLocalEvent(OnEmote, before: new[] { typeof(VocalSystem) }); + SubscribeLocalEvent(OnScreamAction, before: new[] { typeof(VocalSystem) }); } private void OnEmote(EntityUid uid, MutedComponent component, ref EmoteEvent args) @@ -29,6 +30,19 @@ private void OnEmote(EntityUid uid, MutedComponent component, ref EmoteEvent arg args.Handled = true; } + private void OnScreamAction(EntityUid uid, MutedComponent component, ScreamActionEvent args) + { + if (args.Handled) + return; + + if (HasComp(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) { diff --git a/Content.Shared/Speech/ScreamActionEvent.cs b/Content.Shared/Speech/ScreamActionEvent.cs new file mode 100644 index 0000000000..756f65a35d --- /dev/null +++ b/Content.Shared/Speech/ScreamActionEvent.cs @@ -0,0 +1,7 @@ +using Content.Shared.Actions; + +namespace Content.Shared.Speech; + +public sealed partial class ScreamActionEvent : InstantActionEvent +{ +} diff --git a/Resources/Prototypes/Actions/types.yml b/Resources/Prototypes/Actions/types.yml index 43019f44af..c63071551b 100644 --- a/Resources/Prototypes/Actions/types.yml +++ b/Resources/Prototypes/Actions/types.yml @@ -1,3 +1,15 @@ +- type: entity + id: ActionScream + name: Scream + description: AAAAAAAAAAAAAAAAAAAAAAAAA + noSpawn: true + components: + - type: InstantAction + useDelay: 10 + icon: Interface/Actions/scream.png + event: !type:ScreamActionEvent + checkCanInteract: false + - type: entity id: ActionTurnUndead name: Turn Undead diff --git a/Resources/Prototypes/Catalog/catalog.yml b/Resources/Prototypes/Catalog/catalog.yml index f97f4d1993..49cdef2a40 100644 --- a/Resources/Prototypes/Catalog/catalog.yml +++ b/Resources/Prototypes/Catalog/catalog.yml @@ -28,7 +28,7 @@ id: DebugListing4 name: debug name 4 description: debug desc 4 - productAction: ActionSleep + productAction: ActionScream categories: - Debug cost: