From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Date: Mon, 27 Mar 2023 00:47:46 +0000 (+1300)
Subject: Fix auto-emote bug (#14883)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=87185d019c36e9d22614287b940a035a746d466f;p=space-station-14.git
Fix auto-emote bug (#14883)
---
diff --git a/Content.Server/Chat/Systems/AutoEmoteSystem.cs b/Content.Server/Chat/Systems/AutoEmoteSystem.cs
index 7dd4a98a43..f139c9d63c 100644
--- a/Content.Server/Chat/Systems/AutoEmoteSystem.cs
+++ b/Content.Server/Chat/Systems/AutoEmoteSystem.cs
@@ -83,6 +83,8 @@ public sealed class AutoEmoteSystem : EntitySystem
if (!Resolve(uid, ref autoEmote, logMissing: false))
return false;
+ DebugTools.Assert(autoEmote.LifeStage <= ComponentLifeStage.Running);
+
if (autoEmote.Emotes.Contains(autoEmotePrototypeId))
return false;
@@ -93,9 +95,9 @@ public sealed class AutoEmoteSystem : EntitySystem
}
///
- /// Stop preforming an emote.
+ /// Stop preforming an emote. Note that by default this will queue empty components for removal.
///
- public bool RemoveEmote(EntityUid uid, string autoEmotePrototypeId, AutoEmoteComponent? autoEmote = null)
+ public bool RemoveEmote(EntityUid uid, string autoEmotePrototypeId, AutoEmoteComponent? autoEmote = null, bool removeEmpty = true)
{
if (!Resolve(uid, ref autoEmote, logMissing: false))
return false;
@@ -105,7 +107,13 @@ public sealed class AutoEmoteSystem : EntitySystem
if (!autoEmote.EmoteTimers.Remove(autoEmotePrototypeId))
return false;
- autoEmote.NextEmoteTime = autoEmote.EmoteTimers.Values.Min();
+ if (autoEmote.EmoteTimers.Count > 0)
+ autoEmote.NextEmoteTime = autoEmote.EmoteTimers.Values.Min();
+ else if (removeEmpty)
+ RemCompDeferred(uid, autoEmote);
+ else
+ autoEmote.NextEmoteTime = TimeSpan.MaxValue;
+
return true;
}
diff --git a/Content.Server/Chat/Systems/EmoteOnDamageSystem.cs b/Content.Server/Chat/Systems/EmoteOnDamageSystem.cs
index ae14399c25..956a7eb825 100644
--- a/Content.Server/Chat/Systems/EmoteOnDamageSystem.cs
+++ b/Content.Server/Chat/Systems/EmoteOnDamageSystem.cs
@@ -62,21 +62,28 @@ public sealed class EmoteOnDamageSystem : EntitySystem
if (!Resolve(uid, ref emoteOnDamage, logMissing: false))
return false;
+ DebugTools.Assert(emoteOnDamage.LifeStage <= ComponentLifeStage.Running);
DebugTools.Assert(_prototypeManager.HasIndex(emotePrototypeId), "Prototype not found. Did you make a typo?");
return emoteOnDamage.Emotes.Add(emotePrototypeId);
}
///
- /// Stop preforming an emote.
+ /// Stop preforming an emote. Note that by default this will queue empty components for removal.
///
- public bool RemoveEmote(EntityUid uid, string emotePrototypeId, EmoteOnDamageComponent? emoteOnDamage = null)
+ public bool RemoveEmote(EntityUid uid, string emotePrototypeId, EmoteOnDamageComponent? emoteOnDamage = null, bool removeEmpty = true)
{
if (!Resolve(uid, ref emoteOnDamage, logMissing: false))
return false;
DebugTools.Assert(_prototypeManager.HasIndex(emotePrototypeId), "Prototype not found. Did you make a typo?");
- return emoteOnDamage.Emotes.Remove(emotePrototypeId);
+ if (!emoteOnDamage.Emotes.Remove(emotePrototypeId))
+ return false;
+
+ if (removeEmpty && emoteOnDamage.Emotes.Count == 0)
+ RemCompDeferred(uid, emoteOnDamage);
+
+ return true;
}
}