From 088ced8accd110522d1f97100a0d9e1abe5b438e Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Fri, 14 Jun 2024 17:42:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=82=D0=BE=D0=B3=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoPostingChat/AutoPostingChatSystem.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index 2667dae801..b7d6586581 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -26,12 +26,23 @@ public sealed class AutoPostingChatSystem : EntitySystem [Dependency] private readonly DamageableSystem _damageableSystem = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly ChatSystem _chat = default!; + private System.Timers.Timer speakTimer = new(); + private System.Timers.Timer emoteTimer = new(); + public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnComponentStartup); SubscribeLocalEvent(OnMobState); + SubscribeLocalEvent(ComponentRemove); + } + + private void ComponentRemove(EntityUid uid, AutoPostingChatComponent component, ComponentShutdown args) + { + speakTimer.Stop(); + emoteTimer.Stop(); } + /// /// On death removes active comps. /// @@ -53,8 +64,8 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen // Logger.Warning("AutoPostingChatComponent отсутствует на сущности с UID: " + uid); // return; //} - // Создаем таймеры для Speak и Emote - var speakTimer = new System.Timers.Timer(component.SpeakTimerRead); // 8000 миллисекунд = 8 секунд по умолчанию + + speakTimer.Interval = component.SpeakTimerRead; // 8000 миллисекунд = 8 секунд по умолчанию speakTimer.Elapsed += (sender, eventArgs) => { // Проверяем, что данные в компоненте были обновлены @@ -67,7 +78,7 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen } speakTimer.Interval = component.SpeakTimerRead; }; - var emoteTimer = new System.Timers.Timer(component.EmoteTimerRead); // 9000 миллисекунд = 9 секунд по умолчанию + emoteTimer.Interval = component.EmoteTimerRead; // 9000 миллисекунд = 9 секунд по умолчанию emoteTimer.Elapsed += (sender, eventArgs) => { // Проверяем, что данные в компоненте были обновлены