From cd9f84c8c97edfdd3292e1eea09dbadbda6a3ffc Mon Sep 17 00:00:00 2001 From: null <56081759+NullWanderer@users.noreply.github.com> Date: Tue, 7 May 2024 03:05:30 +0200 Subject: [PATCH] Fix for harpy emote conflicts --- .../Chat/Systems/ChatSystem.Emote.cs | 22 +++++++++++++------ .../DeltaV/Voice/speech_emote_sounds.yml | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Content.Server/Chat/Systems/ChatSystem.Emote.cs b/Content.Server/Chat/Systems/ChatSystem.Emote.cs index d120812b88..dfb9347334 100644 --- a/Content.Server/Chat/Systems/ChatSystem.Emote.cs +++ b/Content.Server/Chat/Systems/ChatSystem.Emote.cs @@ -1,4 +1,5 @@ using System.Collections.Frozen; +using System.Collections.Immutable; using Content.Shared.Chat.Prototypes; using Content.Shared.Speech; using Robust.Shared.Prototypes; @@ -9,7 +10,7 @@ namespace Content.Server.Chat.Systems; // emotes using emote prototype public partial class ChatSystem { - private FrozenDictionary _wordEmoteDict = FrozenDictionary.Empty; + private FrozenDictionary> _wordEmoteDict = FrozenDictionary>.Empty; // DeltaV - Multiple emotes protected override void OnPrototypeReload(PrototypesReloadedEventArgs obj) { @@ -20,7 +21,7 @@ public partial class ChatSystem private void CacheEmotes() { - var dict = new Dictionary(); + var dict = new Dictionary>(); // DeltaV - Multiple triggers for the same emote var emotes = _prototypeManager.EnumeratePrototypes(); foreach (var emote in emotes) { @@ -29,12 +30,16 @@ public partial class ChatSystem var lowerWord = word.ToLower(); if (dict.TryGetValue(lowerWord, out var value)) { - var errMsg = $"Duplicate of emote word {lowerWord} in emotes {emote.ID} and {value.ID}"; - Log.Error(errMsg); + // Begin DeltaV modification - Multiple emotes for the same words + dict[lowerWord] = value.Add(emote); + + var errMsg = $"Duplicate of emote word {lowerWord}"; + Log.Warning(errMsg); + continue; } - dict.Add(lowerWord, emote); + dict.Add(lowerWord, ImmutableList.Create(emote)); // End DeltaV modification } } @@ -161,10 +166,13 @@ public partial class ChatSystem private void TryEmoteChatInput(EntityUid uid, string textInput) { var actionLower = textInput.ToLower(); - if (!_wordEmoteDict.TryGetValue(actionLower, out var emote)) + if (!_wordEmoteDict.TryGetValue(actionLower, out var emotes)) return; - InvokeEmoteEvent(uid, emote); + foreach (var emote in emotes) // DeltaV - Multiple emotes for the same trigger + { + InvokeEmoteEvent(uid, emote); + } } private void InvokeEmoteEvent(EntityUid uid, EmotePrototype proto) diff --git a/Resources/Prototypes/DeltaV/Voice/speech_emote_sounds.yml b/Resources/Prototypes/DeltaV/Voice/speech_emote_sounds.yml index f2ef43b6f8..07a9149311 100644 --- a/Resources/Prototypes/DeltaV/Voice/speech_emote_sounds.yml +++ b/Resources/Prototypes/DeltaV/Voice/speech_emote_sounds.yml @@ -60,8 +60,8 @@ collection: VulpkaninHowls Awoo: collection: VulpkaninHowls - Honk: - collection: BikeHorn +# Honk: +# collection: BikeHorn Weh: collection: Weh