From 12b4fd22664578af3dcd314e7dca09448ddbdc4c Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Fri, 27 Sep 2024 22:30:17 -0400 Subject: [PATCH] Fix Moodlet Popup Spam (#948) # Description This fixes a bug whereby smoking a cigarette spams your screen with the funny "I feel as if I have been standing my entire life and I just sat down" message. Now moodlet popups only play once when the moodlet is obtained, rather than being constantly spammed. I have tested this ingame to verify that it works correctly. # Changelog :cl: - fix: Smoking cigarettes or drinking loto oil will no longer spam moodlet popup messages. --- Content.Server/Mood/MoodSystem.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Content.Server/Mood/MoodSystem.cs b/Content.Server/Mood/MoodSystem.cs index 7e4789bf14..079a12d927 100644 --- a/Content.Server/Mood/MoodSystem.cs +++ b/Content.Server/Mood/MoodSystem.cs @@ -122,16 +122,15 @@ private void ApplyEffect(EntityUid uid, MoodComponent component, MoodEffectProto if (!_prototypeManager.TryIndex(oldPrototypeId, out var oldPrototype)) return; - if (prototype.ID != oldPrototype.ID) - { + // Don't send the moodlet popup if we already have the moodlet. + if (!component.CategorisedEffects.ContainsValue(prototype.ID)) SendEffectText(uid, prototype); + + if (prototype.ID != oldPrototype.ID) component.CategorisedEffects[prototype.Category] = prototype.ID; - } } else - { component.CategorisedEffects.Add(prototype.Category, prototype.ID); - } if (prototype.Timeout != 0) Timer.Spawn(TimeSpan.FromSeconds(prototype.Timeout), () => RemoveTimedOutEffect(uid, prototype.ID, prototype.Category)); @@ -146,7 +145,10 @@ private void ApplyEffect(EntityUid uid, MoodComponent component, MoodEffectProto if (moodChange == 0) return; - SendEffectText(uid, prototype); + // Don't send the moodlet popup if we already have the moodlet. + if (!component.UncategorisedEffects.ContainsKey(prototype.ID)) + SendEffectText(uid, prototype); + component.UncategorisedEffects.Add(prototype.ID, moodChange); if (prototype.Timeout != 0)