diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index 641c83f2a9..0cdca28ad5 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -1,12 +1,8 @@ using Content.Server.Administration.Commands; -using Content.Server.Popups; -using Content.Shared.Popups; using Content.Shared.Mobs; using Content.Server.Chat; using Content.Server.Chat.Systems; using Content.Shared.Chat.Prototypes; -using Robust.Shared.Random; -using Content.Shared.Stunnable; using Content.Shared.Damage.Prototypes; using Content.Shared.Damage; using Robust.Shared.Prototypes; @@ -14,18 +10,14 @@ using Content.Server.Speech.EntitySystems; using Content.Shared.ADT.AutoPostingChat; using Content.Shared.Interaction.Components; -using Robust.Shared.Audio; -using Robust.Shared.Audio.Systems; using System.Timers; using System.ComponentModel; using System.Linq; -//using System.Random; using Robust.Shared.Timing; -using Robust.Shared.Utility; public sealed class AutoPostingChatSystem : EntitySystem { - [Dependency] private readonly DamageableSystem _damageableSystem = default!; - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + // [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(); @@ -67,6 +59,12 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen return; } + SetupSpeakTimer(uid, component); + SetupEmoteTimer(uid, component); + } + + private void SetupSpeakTimer(EntityUid uid, AutoPostingChatComponent component) + { _speakTimer.Interval = component.RandomIntervalSpeak ? _random.Next(1000, 30001) : component.SpeakTimerRead; _speakTimer.Elapsed += (sender, eventArgs) => { @@ -77,6 +75,11 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen _speakTimer.Interval = component.RandomIntervalSpeak ? _random.Next(1000, 30001) : component.SpeakTimerRead; }; + _speakTimer.Start(); + } + + private void SetupEmoteTimer(EntityUid uid, AutoPostingChatComponent component) + { _emoteTimer.Interval = component.RandomIntervalEmote ? _random.Next(1000, 30001) : component.EmoteTimerRead; _emoteTimer.Elapsed += (sender, eventArgs) => { @@ -87,7 +90,38 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen _emoteTimer.Interval = component.RandomIntervalEmote ? _random.Next(1000, 30001) : component.EmoteTimerRead; }; - _speakTimer.Start(); _emoteTimer.Start(); } + + // private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent component, ComponentStartup args) + // { + // if (component == null) + // { + // Log.Debug("AutoPostingChatComponent отсутствует на сущности с UID: " + uid); + // return; + // } + + // _speakTimer.Interval = component.RandomIntervalSpeak ? _random.Next(1000, 30001) : component.SpeakTimerRead; + // _speakTimer.Elapsed += (sender, eventArgs) => + // { + // if (component.PostingMessageSpeak != null) + // { + // _chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); + // } + // _speakTimer.Interval = component.RandomIntervalSpeak ? _random.Next(1000, 30001) : component.SpeakTimerRead; + // }; + + // _emoteTimer.Interval = component.RandomIntervalEmote ? _random.Next(1000, 30001) : component.EmoteTimerRead; + // _emoteTimer.Elapsed += (sender, eventArgs) => + // { + // if (component.PostingMessageEmote != null) + // { + // _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); + // } + // _emoteTimer.Interval = component.RandomIntervalEmote ? _random.Next(1000, 30001) : component.EmoteTimerRead; + // }; + + // _speakTimer.Start(); + // _emoteTimer.Start(); + // } } \ No newline at end of file diff --git a/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs index 24dbfbd434..32943b9314 100644 --- a/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs +++ b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs @@ -8,15 +8,13 @@ namespace Content.Shared.ADT.AutoPostingChat; public sealed partial class AutoPostingChatComponent : Component { /// - /// Whether this destination is shown in the gateway ui. - /// If you are making a gateway for an admeme set this once you are ready for players to select it. + ///Sets a random interval after each iteration of spoken messages /// [DataField("randomIntervalSpeak"), ViewVariables(VVAccess.ReadWrite)] public bool RandomIntervalSpeak = false; /// - /// Whether this destination is shown in the gateway ui. - /// If you are making a gateway for an admeme set this once you are ready for players to select it. + /// Sets a random interval after each iteration of spoken emotions /// [DataField("randomIntervalEmote"), ViewVariables(VVAccess.ReadWrite)] public bool RandomIntervalEmote = false;