Skip to content

Commit

Permalink
Вот теперь точно всё, освобождаем ресурсы и небольшая проверка
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 committed Jun 14, 2024
1 parent 9bd8ada commit 1d4c5de
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ private void ComponentRemove(EntityUid uid, AutoPostingChatComponent component,
{
_speakTimer.Stop();
_emoteTimer.Stop();
_speakTimer.Dispose(); // освобождаем ресурсы
_emoteTimer.Dispose();
}

/// <summary>
Expand All @@ -51,29 +53,24 @@ private void OnMobState(EntityUid uid, AutoPostingChatComponent component, MobSt
if (args.NewMobState == MobState.Dead || component == null)
{
RemComp<AutoPostingChatComponent>(uid);
//var damageSpec = new DamageSpecifier(_prototypeManager.Index<DamageGroupPrototype>("Genetic"), 300);
//_damageableSystem.TryChangeDamage(uid, damageSpec);
}
}

private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent component, ComponentStartup args)
{
// Проверяем наличие компонента AutoPostingChatComponent на сущности
//if (component == null)
//{
// Logger.Warning("AutoPostingChatComponent отсутствует на сущности с UID: " + uid);
// return;
//}
// Проверяем наличие компонента AutoPostingChatComponent на сущности
if (component == null)
{
Log.Debug("AutoPostingChatComponent отсутствует на сущности с UID: " + uid);
return;
}

_speakTimer.Interval = component.SpeakTimerRead; // 8000 миллисекунд = 8 секунд по умолчанию
_speakTimer.Elapsed += (sender, eventArgs) =>
{
// Проверяем, что данные в компоненте были обновлены
if (component.PostingMessageSpeak != null)
{
//if (component.PostingMessageSpeak == "")
// _speakTimer.Stop();

_chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal);
}
_speakTimer.Interval = component.SpeakTimerRead;
Expand All @@ -84,8 +81,6 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen
// Проверяем, что данные в компоненте были обновлены
if (component.PostingMessageEmote != null)
{
//if (component.PostingMessageEmote == "")
// _emoteTimer.Stop();
_chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal);
}
_emoteTimer.Interval = component.EmoteTimerRead;
Expand All @@ -94,4 +89,4 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen
_speakTimer.Start();
_emoteTimer.Start();
}
}
}

0 comments on commit 1d4c5de

Please sign in to comment.