Fix for harpy emote conflicts

This commit is contained in:
null 2024-05-07 03:05:30 +02:00
parent c3017f773f
commit cd9f84c8c9
No known key found for this signature in database
GPG Key ID: 212F05528FD678BE
2 changed files with 17 additions and 9 deletions

View File

@ -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<string, EmotePrototype> _wordEmoteDict = FrozenDictionary<string, EmotePrototype>.Empty;
private FrozenDictionary<string, ImmutableList<EmotePrototype>> _wordEmoteDict = FrozenDictionary<string, ImmutableList<EmotePrototype>>.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<string, EmotePrototype>();
var dict = new Dictionary<string, ImmutableList<EmotePrototype>>(); // DeltaV - Multiple triggers for the same emote
var emotes = _prototypeManager.EnumeratePrototypes<EmotePrototype>();
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)

View File

@ -60,8 +60,8 @@
collection: VulpkaninHowls
Awoo:
collection: VulpkaninHowls
Honk:
collection: BikeHorn
# Honk:
# collection: BikeHorn
Weh:
collection: Weh