From 9771e1a87f70eb1b3410765304df2b65fb5402de Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Sun, 31 Mar 2024 02:29:08 +0300 Subject: [PATCH 01/14] Add new component --- .../ADT/PostingChat/PostingChatSystem.cs | 106 ++++++++++++++++++ .../ADT/PostingChat/PostingChatComponent.cs | 29 +++++ 2 files changed, 135 insertions(+) create mode 100644 Content.Server/ADT/PostingChat/PostingChatSystem.cs create mode 100644 Content.Shared/ADT/PostingChat/PostingChatComponent.cs diff --git a/Content.Server/ADT/PostingChat/PostingChatSystem.cs b/Content.Server/ADT/PostingChat/PostingChatSystem.cs new file mode 100644 index 00000000000..685e5b15796 --- /dev/null +++ b/Content.Server/ADT/PostingChat/PostingChatSystem.cs @@ -0,0 +1,106 @@ +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; +using Content.Server.Emoting.Systems; +using Content.Server.Speech.EntitySystems; +using Content.Shared.ADT.PostingChat; +using Content.Shared.Interaction.Components; +using Robust.Shared.Audio; +using Robust.Shared.Audio.Systems; +using System.Timers; +using System.ComponentModel; +using System; +using System.Linq; +using Robust.Shared.Timing; +using Robust.Shared.Utility; + +public sealed class PostingChatSystem : EntitySystem +{ + [Dependency] private readonly PopupSystem _popupSystem = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly SharedStunSystem _stunSystem = default!; + [Dependency] private readonly DamageableSystem _damageableSystem = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly ChatSystem _chat = default!; + [Dependency] private readonly AutoEmoteSystem _autoEmote = default!; + [Dependency] private readonly MetaDataSystem _metaData = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnComponentStartup); + SubscribeLocalEvent(OnMobState); + SubscribeLocalEvent(OnEmote, before: + new[] { typeof(VocalSystem), typeof(BodyEmotesSystem) }); + } + + /// + /// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning. + /// + private void OnMobState(EntityUid uid, PostingChatComponent component, MobStateChangedEvent args) + { + if (args.NewMobState == MobState.Dead) + { + RemComp(uid); + RemComp(uid); + RemComp(uid); + var damageSpec = new DamageSpecifier(_prototypeManager.Index("Genetic"), 300); + _damageableSystem.TryChangeDamage(uid, damageSpec); + } + } + + public EmoteSoundsPrototype? EmoteSounds; + + /// + /// OnStartup gives the PostingChat outfit, ensures clumsy, gives name prefix and makes sure emote sounds are laugh. + /// + private void OnComponentStartup(EntityUid uid, PostingChatComponent component, ComponentStartup args) + { + //if (component.EmoteSoundsId == null) + // return; + //_prototypeManager.TryIndex(component.EmoteSoundsId, out EmoteSounds); + + var meta = MetaData(uid); + var name = meta.EntityName; + + EnsureComp(uid); + + + _autoEmote.AddEmote(uid, "CluwneGiggle"); + + _autoEmote.AddEmote(uid, component.PostingMessageEmote); + + + EnsureComp(uid); + } + + + + /// + /// . + /// + private void OnEmote(EntityUid uid, PostingChatComponent component, ref EmoteEvent args) + { + if (args.Handled) + return; + args.Handled = _chat.TryPlayEmoteSound(uid, EmoteSounds, args.Emote); + + if (_robustRandom.Prob(component.GiggleRandomChance)) + { + //_audio.PlayPvs(component.SpawnSound, uid); + _chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); + _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); + } + } +} diff --git a/Content.Shared/ADT/PostingChat/PostingChatComponent.cs b/Content.Shared/ADT/PostingChat/PostingChatComponent.cs new file mode 100644 index 00000000000..bb80f431617 --- /dev/null +++ b/Content.Shared/ADT/PostingChat/PostingChatComponent.cs @@ -0,0 +1,29 @@ +using Robust.Shared.Audio; +using Content.Shared.Chat.Prototypes; +using Robust.Shared.GameStates; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; + +namespace Content.Shared.ADT.PostingChat; + +[RegisterComponent] +[NetworkedComponent] +public sealed partial class PostingChatComponent : Component +{ + /// + /// timings for giggles and knocks. + /// + [ViewVariables(VVAccess.ReadWrite)] + public TimeSpan DamageGiggleCooldown = TimeSpan.FromSeconds(2); + + //[ViewVariables(VVAccess.ReadWrite)] + //public float KnockChance = 0.05f; + + [ViewVariables(VVAccess.ReadWrite)] + public float GiggleRandomChance = 0.3f; + + [DataField("speakMessage")] + public string? PostingMessageSpeak = "Вульп-вульп!"; + + [DataField("emoteMessage")] + public string? PostingMessageEmote = "Кхе"; +} From ecb511d001e0553bb58f531eabd413c70126fdb1 Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Tue, 2 Apr 2024 00:04:40 +0300 Subject: [PATCH 02/14] =?UTF-8?q?=D0=9D=D1=83=20=D1=81=D0=BE=D0=B1=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B5=D0=BD=D0=BD=D0=BE=20=D0=B2=D1=81=D1=91=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoPostingChat/AutoPostingChatSystem.cs | 158 ++++++++++++++++++ .../ADT/PostingChat/PostingChatSystem.cs | 106 ------------ .../AutoPostingChatComponent.cs} | 22 ++- 3 files changed, 174 insertions(+), 112 deletions(-) create mode 100644 Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs delete mode 100644 Content.Server/ADT/PostingChat/PostingChatSystem.cs rename Content.Shared/ADT/{PostingChat/PostingChatComponent.cs => AutoPostingChat/AutoPostingChatComponent.cs} (59%) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs new file mode 100644 index 00000000000..ab54261027e --- /dev/null +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -0,0 +1,158 @@ +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; +using Content.Server.Emoting.Systems; +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 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 ChatSystem _chat = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnComponentStartup); + SubscribeLocalEvent(OnMobState); + } + /// + /// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning. + /// + private void OnMobState(EntityUid uid, AutoPostingChatComponent component, MobStateChangedEvent args) + { + if (args.NewMobState == MobState.Dead || component == null) + { + RemComp(uid); + var damageSpec = new DamageSpecifier(_prototypeManager.Index("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; + //} + + // Создаем таймеры для Speak и Emote + var speakTimer = new System.Timers.Timer(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); + } + }; + var emoteTimer = new System.Timers.Timer(component.EmoteTimerRead); // 9000 миллисекунд = 9 секунд по умолчанию + emoteTimer.Elapsed += (sender, eventArgs) => + { + // Проверяем, что данные в компоненте были обновлены + if (component.PostingMessageEmote != null) + { + //if (component.PostingMessageEmote == "") + // emoteTimer.Stop(); + + _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); + } + }; + // Запускаем таймеры + speakTimer.Start(); + emoteTimer.Start(); + } + + //// Метод для обновления времени таймера Emote + //public void UpdateEmoteTimer(int newTimeInSeconds) + //{ + // emoteTimer.Interval = newTimeInSeconds * 1000; // Преобразуем секунды в миллисекунды + //} + +} +//public EmoteSoundsPrototype? EmoteSounds; +///// +///// OnStartup gives the AutoPostingChat outfit, ensures clumsy, gives name prefix and makes sure emote sounds are laugh. +///// +//private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent component, ComponentStartup args) +//{ +// //if (component.EmoteSoundsId == null) +// // return; +// //_prototypeManager.TryIndex(component.EmoteSoundsId, out EmoteSounds); +// //var meta = MetaData(uid); +// //var name = meta.EntityName; +// //EnsureComp(uid); +// //_autoEmote.AddEmote(uid, component.PostingMessageEmote); +// //_autoEmote.AddEmote(uid, component.PostingMessageEmote); +// //EnsureComp(uid); +// _chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); +// _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); +//} + +//private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent component, ComponentStartup args) +//{ +// // Проверяем наличие компонента AutoPostingChatComponent на сущности +// //if (component == null) +// //{ +// // Logger.Warning("AutoPostingChatComponent отсутствует на сущности с UID: " + uid); +// // return; +// //} + +// // Создаем таймеры для Speak и Emote +// var speakTimer = new System.Timers.Timer(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); +// } +// }; +// var emoteTimer = new System.Timers.Timer(component.EmoteTimerRead); // 9000 миллисекунд = 9 секунд +// emoteTimer.Elapsed += (sender, eventArgs) => +// { +// // Проверяем, что данные в компоненте были обновлены +// if (component.PostingMessageEmote != null) +// { +// //if (component.PostingMessageEmote == "") +// // emoteTimer.Stop(); + +// _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); +// } +// }; +// // Запускаем таймеры +// speakTimer.Start(); +// emoteTimer.Start(); +//} + +//private System.Timers.Timer emoteTimer; diff --git a/Content.Server/ADT/PostingChat/PostingChatSystem.cs b/Content.Server/ADT/PostingChat/PostingChatSystem.cs deleted file mode 100644 index 685e5b15796..00000000000 --- a/Content.Server/ADT/PostingChat/PostingChatSystem.cs +++ /dev/null @@ -1,106 +0,0 @@ -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; -using Content.Server.Emoting.Systems; -using Content.Server.Speech.EntitySystems; -using Content.Shared.ADT.PostingChat; -using Content.Shared.Interaction.Components; -using Robust.Shared.Audio; -using Robust.Shared.Audio.Systems; -using System.Timers; -using System.ComponentModel; -using System; -using System.Linq; -using Robust.Shared.Timing; -using Robust.Shared.Utility; - -public sealed class PostingChatSystem : EntitySystem -{ - [Dependency] private readonly PopupSystem _popupSystem = default!; - [Dependency] private readonly SharedAudioSystem _audio = default!; - [Dependency] private readonly IRobustRandom _robustRandom = default!; - [Dependency] private readonly SharedStunSystem _stunSystem = default!; - [Dependency] private readonly DamageableSystem _damageableSystem = default!; - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - [Dependency] private readonly ChatSystem _chat = default!; - [Dependency] private readonly AutoEmoteSystem _autoEmote = default!; - [Dependency] private readonly MetaDataSystem _metaData = default!; - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnComponentStartup); - SubscribeLocalEvent(OnMobState); - SubscribeLocalEvent(OnEmote, before: - new[] { typeof(VocalSystem), typeof(BodyEmotesSystem) }); - } - - /// - /// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning. - /// - private void OnMobState(EntityUid uid, PostingChatComponent component, MobStateChangedEvent args) - { - if (args.NewMobState == MobState.Dead) - { - RemComp(uid); - RemComp(uid); - RemComp(uid); - var damageSpec = new DamageSpecifier(_prototypeManager.Index("Genetic"), 300); - _damageableSystem.TryChangeDamage(uid, damageSpec); - } - } - - public EmoteSoundsPrototype? EmoteSounds; - - /// - /// OnStartup gives the PostingChat outfit, ensures clumsy, gives name prefix and makes sure emote sounds are laugh. - /// - private void OnComponentStartup(EntityUid uid, PostingChatComponent component, ComponentStartup args) - { - //if (component.EmoteSoundsId == null) - // return; - //_prototypeManager.TryIndex(component.EmoteSoundsId, out EmoteSounds); - - var meta = MetaData(uid); - var name = meta.EntityName; - - EnsureComp(uid); - - - _autoEmote.AddEmote(uid, "CluwneGiggle"); - - _autoEmote.AddEmote(uid, component.PostingMessageEmote); - - - EnsureComp(uid); - } - - - - /// - /// . - /// - private void OnEmote(EntityUid uid, PostingChatComponent component, ref EmoteEvent args) - { - if (args.Handled) - return; - args.Handled = _chat.TryPlayEmoteSound(uid, EmoteSounds, args.Emote); - - if (_robustRandom.Prob(component.GiggleRandomChance)) - { - //_audio.PlayPvs(component.SpawnSound, uid); - _chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); - _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); - } - } -} diff --git a/Content.Shared/ADT/PostingChat/PostingChatComponent.cs b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs similarity index 59% rename from Content.Shared/ADT/PostingChat/PostingChatComponent.cs rename to Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs index bb80f431617..cd8606c08c6 100644 --- a/Content.Shared/ADT/PostingChat/PostingChatComponent.cs +++ b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs @@ -3,27 +3,37 @@ using Robust.Shared.GameStates; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -namespace Content.Shared.ADT.PostingChat; +namespace Content.Shared.ADT.AutoPostingChat; [RegisterComponent] [NetworkedComponent] -public sealed partial class PostingChatComponent : Component +public sealed partial class AutoPostingChatComponent : Component { /// /// timings for giggles and knocks. /// - [ViewVariables(VVAccess.ReadWrite)] - public TimeSpan DamageGiggleCooldown = TimeSpan.FromSeconds(2); + //[ViewVariables(VVAccess.ReadWrite)] + //public TimeSpan DamageGiggleCooldown = TimeSpan.FromSeconds(2); //[ViewVariables(VVAccess.ReadWrite)] //public float KnockChance = 0.05f; + //[ViewVariables(VVAccess.ReadWrite)] + //public float GiggleRandomChance = 0.3f; + + + [ViewVariables(VVAccess.ReadWrite)] + public int SpeakTimerRead = 8000; [ViewVariables(VVAccess.ReadWrite)] - public float GiggleRandomChance = 0.3f; + public int EmoteTimerRead = 9000; - [DataField("speakMessage")] + [DataField("speakMessage")] public string? PostingMessageSpeak = "Вульп-вульп!"; + [DataField("emoteMessage")] public string? PostingMessageEmote = "Кхе"; + + + } From 3b0868fa12c99936f4fba70fc776fab90824bb45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Sat, 6 Apr 2024 18:34:06 +0300 Subject: [PATCH 03/14] Update AutoPostingChatSystem.cs --- .../AutoPostingChat/AutoPostingChatSystem.cs | 71 +------------------ 1 file changed, 3 insertions(+), 68 deletions(-) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index ab54261027e..955506af0b3 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -38,15 +38,15 @@ public override void Initialize() SubscribeLocalEvent(OnMobState); } /// - /// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning. + /// On death removes active comps. /// private void OnMobState(EntityUid uid, AutoPostingChatComponent component, MobStateChangedEvent args) { if (args.NewMobState == MobState.Dead || component == null) { RemComp(uid); - var damageSpec = new DamageSpecifier(_prototypeManager.Index("Genetic"), 300); - _damageableSystem.TryChangeDamage(uid, damageSpec); + //var damageSpec = new DamageSpecifier(_prototypeManager.Index("Genetic"), 300); + //_damageableSystem.TryChangeDamage(uid, damageSpec); } } @@ -90,69 +90,4 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen emoteTimer.Start(); } - //// Метод для обновления времени таймера Emote - //public void UpdateEmoteTimer(int newTimeInSeconds) - //{ - // emoteTimer.Interval = newTimeInSeconds * 1000; // Преобразуем секунды в миллисекунды - //} - -} -//public EmoteSoundsPrototype? EmoteSounds; -///// -///// OnStartup gives the AutoPostingChat outfit, ensures clumsy, gives name prefix and makes sure emote sounds are laugh. -///// -//private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent component, ComponentStartup args) -//{ -// //if (component.EmoteSoundsId == null) -// // return; -// //_prototypeManager.TryIndex(component.EmoteSoundsId, out EmoteSounds); -// //var meta = MetaData(uid); -// //var name = meta.EntityName; -// //EnsureComp(uid); -// //_autoEmote.AddEmote(uid, component.PostingMessageEmote); -// //_autoEmote.AddEmote(uid, component.PostingMessageEmote); -// //EnsureComp(uid); -// _chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); -// _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); -//} - -//private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent component, ComponentStartup args) -//{ -// // Проверяем наличие компонента AutoPostingChatComponent на сущности -// //if (component == null) -// //{ -// // Logger.Warning("AutoPostingChatComponent отсутствует на сущности с UID: " + uid); -// // return; -// //} - -// // Создаем таймеры для Speak и Emote -// var speakTimer = new System.Timers.Timer(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); -// } -// }; -// var emoteTimer = new System.Timers.Timer(component.EmoteTimerRead); // 9000 миллисекунд = 9 секунд -// emoteTimer.Elapsed += (sender, eventArgs) => -// { -// // Проверяем, что данные в компоненте были обновлены -// if (component.PostingMessageEmote != null) -// { -// //if (component.PostingMessageEmote == "") -// // emoteTimer.Stop(); - -// _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); -// } -// }; -// // Запускаем таймеры -// speakTimer.Start(); -// emoteTimer.Start(); -//} - //private System.Timers.Timer emoteTimer; From 09d89de931ecd8717d7b55984f10a913b659ae4a Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Sat, 6 Apr 2024 18:41:22 +0300 Subject: [PATCH 04/14] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADT/AutoPostingChat/AutoPostingChatSystem.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index 955506af0b3..2d8c2939445 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -21,19 +21,14 @@ using System.Linq; 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 ChatSystem _chat = default!; - public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnComponentStartup); SubscribeLocalEvent(OnMobState); } @@ -49,8 +44,6 @@ private void OnMobState(EntityUid uid, AutoPostingChatComponent component, MobSt //_damageableSystem.TryChangeDamage(uid, damageSpec); } } - - private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent component, ComponentStartup args) { // Проверяем наличие компонента AutoPostingChatComponent на сущности @@ -59,7 +52,6 @@ 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.Elapsed += (sender, eventArgs) => @@ -81,7 +73,6 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen { //if (component.PostingMessageEmote == "") // emoteTimer.Stop(); - _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); } }; @@ -89,5 +80,4 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen speakTimer.Start(); emoteTimer.Start(); } - -//private System.Timers.Timer emoteTimer; +} From 31fe203f60390bb0bc95f33aac365b2cebe4d4e9 Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Sat, 6 Apr 2024 18:49:04 +0300 Subject: [PATCH 05/14] =?UTF-8?q?=D0=98=20=D1=82=D1=83=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADT/AutoPostingChat/AutoPostingChatSystem.cs | 1 + .../ADT/AutoPostingChat/AutoPostingChatComponent.cs | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index 2d8c2939445..9e9d4c1416b 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -44,6 +44,7 @@ private void OnMobState(EntityUid uid, AutoPostingChatComponent component, MobSt //_damageableSystem.TryChangeDamage(uid, damageSpec); } } + private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent component, ComponentStartup args) { // Проверяем наличие компонента AutoPostingChatComponent на сущности diff --git a/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs index cd8606c08c6..3f909936727 100644 --- a/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs +++ b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs @@ -2,9 +2,7 @@ using Content.Shared.Chat.Prototypes; using Robust.Shared.GameStates; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; - namespace Content.Shared.ADT.AutoPostingChat; - [RegisterComponent] [NetworkedComponent] public sealed partial class AutoPostingChatComponent : Component @@ -14,13 +12,11 @@ public sealed partial class AutoPostingChatComponent : Component /// //[ViewVariables(VVAccess.ReadWrite)] //public TimeSpan DamageGiggleCooldown = TimeSpan.FromSeconds(2); - //[ViewVariables(VVAccess.ReadWrite)] //public float KnockChance = 0.05f; //[ViewVariables(VVAccess.ReadWrite)] //public float GiggleRandomChance = 0.3f; - [ViewVariables(VVAccess.ReadWrite)] public int SpeakTimerRead = 8000; @@ -30,10 +26,6 @@ public sealed partial class AutoPostingChatComponent : Component [DataField("speakMessage")] public string? PostingMessageSpeak = "Вульп-вульп!"; - [DataField("emoteMessage")] public string? PostingMessageEmote = "Кхе"; - - - } From 115cc616befa0594a239916831002fb1ddb8cac5 Mon Sep 17 00:00:00 2001 From: MODERN <87994977+modern-nm@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:14:17 +0300 Subject: [PATCH 06/14] vv timers edit now work properly --- Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index 9e9d4c1416b..2667dae8018 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -65,6 +65,7 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen _chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); } + speakTimer.Interval = component.SpeakTimerRead; }; var emoteTimer = new System.Timers.Timer(component.EmoteTimerRead); // 9000 миллисекунд = 9 секунд по умолчанию emoteTimer.Elapsed += (sender, eventArgs) => @@ -76,6 +77,7 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen // emoteTimer.Stop(); _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); } + emoteTimer.Interval = component.EmoteTimerRead; }; // Запускаем таймеры speakTimer.Start(); From f3732df23fc703b052fdd9f72e5ad7c7560b3095 Mon Sep 17 00:00:00 2001 From: MODERN <87994977+modern-nm@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:14:17 +0300 Subject: [PATCH 07/14] vv timers edit now work properly --- Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index 9e9d4c1416b..2667dae8018 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -65,6 +65,7 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen _chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); } + speakTimer.Interval = component.SpeakTimerRead; }; var emoteTimer = new System.Timers.Timer(component.EmoteTimerRead); // 9000 миллисекунд = 9 секунд по умолчанию emoteTimer.Elapsed += (sender, eventArgs) => @@ -76,6 +77,7 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen // emoteTimer.Stop(); _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); } + emoteTimer.Interval = component.EmoteTimerRead; }; // Запускаем таймеры speakTimer.Start(); From 088ced8accd110522d1f97100a0d9e1abe5b438e Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Fri, 14 Jun 2024 17:42:31 +0300 Subject: [PATCH 08/14] =?UTF-8?q?=D0=98=D1=82=D0=BE=D0=B3=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=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 2667dae8018..b7d65865815 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) => { // Проверяем, что данные в компоненте были обновлены From 9bd8ada3bac8dc4e4016681f3f0c79930a0b82fb Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Fri, 14 Jun 2024 17:46:56 +0300 Subject: [PATCH 09/14] =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8F=D0=B5=D0=BC=20?= =?UTF-8?q?=D0=B8=D0=BC=D0=B5=D0=BD=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoPostingChat/AutoPostingChatSystem.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index b7d65865815..1bbd84889e2 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -26,8 +26,8 @@ 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(); + private System.Timers.Timer _speakTimer = new(); + private System.Timers.Timer _emoteTimer = new(); public override void Initialize() { @@ -39,8 +39,8 @@ public override void Initialize() private void ComponentRemove(EntityUid uid, AutoPostingChatComponent component, ComponentShutdown args) { - speakTimer.Stop(); - emoteTimer.Stop(); + _speakTimer.Stop(); + _emoteTimer.Stop(); } /// @@ -65,33 +65,33 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen // return; //} - speakTimer.Interval = component.SpeakTimerRead; // 8000 миллисекунд = 8 секунд по умолчанию - speakTimer.Elapsed += (sender, eventArgs) => + _speakTimer.Interval = component.SpeakTimerRead; // 8000 миллисекунд = 8 секунд по умолчанию + _speakTimer.Elapsed += (sender, eventArgs) => { // Проверяем, что данные в компоненте были обновлены if (component.PostingMessageSpeak != null) { //if (component.PostingMessageSpeak == "") - // speakTimer.Stop(); + // _speakTimer.Stop(); _chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); } - speakTimer.Interval = component.SpeakTimerRead; + _speakTimer.Interval = component.SpeakTimerRead; }; - emoteTimer.Interval = component.EmoteTimerRead; // 9000 миллисекунд = 9 секунд по умолчанию - emoteTimer.Elapsed += (sender, eventArgs) => + _emoteTimer.Interval = component.EmoteTimerRead; // 9000 миллисекунд = 9 секунд по умолчанию + _emoteTimer.Elapsed += (sender, eventArgs) => { // Проверяем, что данные в компоненте были обновлены if (component.PostingMessageEmote != null) { //if (component.PostingMessageEmote == "") - // emoteTimer.Stop(); + // _emoteTimer.Stop(); _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); } - emoteTimer.Interval = component.EmoteTimerRead; + _emoteTimer.Interval = component.EmoteTimerRead; }; // Запускаем таймеры - speakTimer.Start(); - emoteTimer.Start(); + _speakTimer.Start(); + _emoteTimer.Start(); } } From 1d4c5de39adffd2a92bc9df5b862cb715402d04d Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Fri, 14 Jun 2024 18:00:23 +0300 Subject: [PATCH 10/14] =?UTF-8?q?=D0=92=D0=BE=D1=82=20=D1=82=D0=B5=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D1=8C=20=D1=82=D0=BE=D1=87=D0=BD=D0=BE=20=D0=B2?= =?UTF-8?q?=D1=81=D1=91,=20=D0=BE=D1=81=D0=B2=D0=BE=D0=B1=D0=BE=D0=B6?= =?UTF-8?q?=D0=B4=D0=B0=D0=B5=D0=BC=20=D1=80=D0=B5=D1=81=D1=83=D1=80=D1=81?= =?UTF-8?q?=D1=8B=20=D0=B8=20=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoPostingChat/AutoPostingChatSystem.cs | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index 1bbd84889e2..ace44a92b1d 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -41,6 +41,8 @@ private void ComponentRemove(EntityUid uid, AutoPostingChatComponent component, { _speakTimer.Stop(); _emoteTimer.Stop(); + _speakTimer.Dispose(); // освобождаем ресурсы + _emoteTimer.Dispose(); } /// @@ -51,19 +53,17 @@ private void OnMobState(EntityUid uid, AutoPostingChatComponent component, MobSt if (args.NewMobState == MobState.Dead || component == null) { RemComp(uid); - //var damageSpec = new DamageSpecifier(_prototypeManager.Index("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) => @@ -71,9 +71,6 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen // Проверяем, что данные в компоненте были обновлены if (component.PostingMessageSpeak != null) { - //if (component.PostingMessageSpeak == "") - // _speakTimer.Stop(); - _chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); } _speakTimer.Interval = component.SpeakTimerRead; @@ -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; @@ -94,4 +89,4 @@ private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent componen _speakTimer.Start(); _emoteTimer.Start(); } -} +} \ No newline at end of file From 3563f1825d5e4d88ebf407f005d4769f98541d9e Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Mon, 17 Jun 2024 19:57:20 +0300 Subject: [PATCH 11/14] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=84=D0=BB=D0=B0=D0=B3=20=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B8=D0=BD=D1=82?= =?UTF-8?q?=D0=B5=D1=80=D0=B2=D0=B0=D0=BB=D0=B0=20=D0=BE=D1=82=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B8=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9=20=D0=B2=20=D0=BF=D1=80=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B0=D1=85=201-30=20=D1=81=D0=B5=D0=BA=D1=83=D0=BD?= =?UTF-8?q?=D0=B4,=20=D1=82=D0=B5=D1=80=D0=BD=D0=B0=D1=80=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BE=D0=BF=D0=B5=D1=80=D0=B0=D1=82=D0=BE=D1=80=D1=8B?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D1=83=D0=BF=D1=80=D0=BE=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=BE=D0=B4=D0=B0=20=D0=B8=20=D0=BE?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=B1=D1=8A?= =?UTF-8?q?=D1=8F=D0=B2=D0=BB=D1=91=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9=20=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D1=82=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoPostingChat/AutoPostingChatSystem.cs | 19 ++++++----- .../AutoPostingChatComponent.cs | 34 ++++++++++++++----- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index ace44a92b1d..641c83f2a97 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -19,6 +19,7 @@ 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 @@ -28,6 +29,8 @@ public sealed class AutoPostingChatSystem : EntitySystem [Dependency] private readonly ChatSystem _chat = default!; private System.Timers.Timer _speakTimer = new(); private System.Timers.Timer _emoteTimer = new(); + private readonly Random _random = new Random(); + //private static readonly Random _random = new Random(); public override void Initialize() { @@ -58,34 +61,32 @@ private void OnMobState(EntityUid uid, AutoPostingChatComponent component, MobSt private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent component, ComponentStartup args) { - // Проверяем наличие компонента AutoPostingChatComponent на сущности - if (component == null) + if (component == null) { Log.Debug("AutoPostingChatComponent отсутствует на сущности с UID: " + uid); return; } - _speakTimer.Interval = component.SpeakTimerRead; // 8000 миллисекунд = 8 секунд по умолчанию + _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.SpeakTimerRead; + _speakTimer.Interval = component.RandomIntervalSpeak ? _random.Next(1000, 30001) : component.SpeakTimerRead; }; - _emoteTimer.Interval = component.EmoteTimerRead; // 9000 миллисекунд = 9 секунд по умолчанию + + _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.EmoteTimerRead; + _emoteTimer.Interval = component.RandomIntervalEmote ? _random.Next(1000, 30001) : component.EmoteTimerRead; }; - // Запускаем таймеры + _speakTimer.Start(); _emoteTimer.Start(); } diff --git a/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs index 3f909936727..5ba30ab5d64 100644 --- a/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs +++ b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs @@ -8,24 +8,40 @@ namespace Content.Shared.ADT.AutoPostingChat; public sealed partial class AutoPostingChatComponent : Component { /// - /// timings for giggles and knocks. + /// 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. /// - //[ViewVariables(VVAccess.ReadWrite)] - //public TimeSpan DamageGiggleCooldown = TimeSpan.FromSeconds(2); - //[ViewVariables(VVAccess.ReadWrite)] - //public float KnockChance = 0.05f; - //[ViewVariables(VVAccess.ReadWrite)] - //public float GiggleRandomChance = 0.3f; + [DataField, 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. + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public bool RandomIntervalEmote = false; + + /// + /// The interval in milliseconds between automatic speech messages. + /// [ViewVariables(VVAccess.ReadWrite)] public int SpeakTimerRead = 8000; + /// + /// The interval in milliseconds between automatic emote messages. + /// [ViewVariables(VVAccess.ReadWrite)] public int EmoteTimerRead = 9000; + /// + /// The message that will be automatically spoken by the entity. + /// [DataField("speakMessage")] - public string? PostingMessageSpeak = "Вульп-вульп!"; + public string? PostingMessageSpeak = ""; + /// + /// The message that will be automatically emotes by the entity. + /// [DataField("emoteMessage")] - public string? PostingMessageEmote = "Кхе"; + public string? PostingMessageEmote = ""; } From f54852145f0d2cc4b1bd86e1760d086e3ce167a0 Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Mon, 17 Jun 2024 23:49:51 +0300 Subject: [PATCH 12/14] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BF=D0=BE=D0=BB=D1=8F=20=D0=B4=D0=BB=D1=8F=20YAML?= =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADT/AutoPostingChat/AutoPostingChatComponent.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs index 5ba30ab5d64..24dbfbd4347 100644 --- a/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs +++ b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs @@ -11,26 +11,28 @@ 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. /// - [DataField, ViewVariables(VVAccess.ReadWrite)] + [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. /// - [DataField, ViewVariables(VVAccess.ReadWrite)] + [DataField("randomIntervalEmote"), ViewVariables(VVAccess.ReadWrite)] public bool RandomIntervalEmote = false; /// /// The interval in milliseconds between automatic speech messages. /// [ViewVariables(VVAccess.ReadWrite)] + [DataField("speakTimer")] public int SpeakTimerRead = 8000; /// /// The interval in milliseconds between automatic emote messages. /// [ViewVariables(VVAccess.ReadWrite)] + [DataField("emoteTimer")] public int EmoteTimerRead = 9000; /// From cc9b5c24b8d81077d3f72d6a8d8ed05e1c4d0984 Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Thu, 20 Jun 2024 01:21:03 +0300 Subject: [PATCH 13/14] =?UTF-8?q?=D0=A0=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoPostingChat/AutoPostingChatSystem.cs | 56 +++++++++++++++---- .../AutoPostingChatComponent.cs | 6 +- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index 641c83f2a97..0cdca28ad54 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 24dbfbd4347..32943b93147 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; From aa920cab244f7ee6691ca3a3b54d443a48ea21d3 Mon Sep 17 00:00:00 2001 From: Schrodinger71 Date: Fri, 21 Jun 2024 21:54:59 +0300 Subject: [PATCH 14/14] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoPostingChat/AutoPostingChatSystem.cs | 27 +++++++------ .../AutoPostingChatComponent.cs | 38 ++++++++++++++++--- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs index 0cdca28ad54..bc3cd087e5d 100644 --- a/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs +++ b/Content.Server/ADT/AutoPostingChat/AutoPostingChatSystem.cs @@ -14,14 +14,16 @@ using System.ComponentModel; using System.Linq; using Robust.Shared.Timing; +using Robust.Shared.Random; public sealed class AutoPostingChatSystem : EntitySystem { // [Dependency] private readonly DamageableSystem _damageableSystem = default!; // [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly ChatSystem _chat = default!; + [Dependency] private readonly IRobustRandom _random = default!; private System.Timers.Timer _speakTimer = new(); private System.Timers.Timer _emoteTimer = new(); - private readonly Random _random = new Random(); + //private readonly Random _random = new Random(); //private static readonly Random _random = new Random(); public override void Initialize() @@ -45,7 +47,7 @@ private void ComponentRemove(EntityUid uid, AutoPostingChatComponent component, /// private void OnMobState(EntityUid uid, AutoPostingChatComponent component, MobStateChangedEvent args) { - if (args.NewMobState == MobState.Dead || component == null) + if (args.NewMobState == MobState.Dead) { RemComp(uid); } @@ -53,26 +55,22 @@ private void OnMobState(EntityUid uid, AutoPostingChatComponent component, MobSt private void OnComponentStartup(EntityUid uid, AutoPostingChatComponent component, ComponentStartup args) { - if (component == null) - { - Log.Debug("AutoPostingChatComponent отсутствует на сущности с UID: " + uid); - return; - } - SetupSpeakTimer(uid, component); SetupEmoteTimer(uid, component); } private void SetupSpeakTimer(EntityUid uid, AutoPostingChatComponent component) { - _speakTimer.Interval = component.RandomIntervalSpeak ? _random.Next(1000, 30001) : component.SpeakTimerRead; + //var msg = _random.Pick(component.SpeakTimerRead); + _speakTimer.Interval = component.RandomIntervalSpeak ? _random.Next(component.MinRandomIntervalSpeak*1000, component.MaxRandomIntervalSpeak*1000) : component.SpeakTimerRead*1000; _speakTimer.Elapsed += (sender, eventArgs) => { if (component.PostingMessageSpeak != null) { - _chat.TrySendInGameICMessage(uid, component.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); + _chat.TrySendInGameICMessage(uid, _random.Pick(component.PostingMessageSpeak), + InGameICChatType.Speak, ChatTransmitRange.Normal); } - _speakTimer.Interval = component.RandomIntervalSpeak ? _random.Next(1000, 30001) : component.SpeakTimerRead; + _speakTimer.Interval = component.RandomIntervalSpeak ? _random.Next(component.MinRandomIntervalSpeak*1000, component.MaxRandomIntervalSpeak*1000) : component.SpeakTimerRead*1000; }; _speakTimer.Start(); @@ -80,14 +78,15 @@ private void SetupSpeakTimer(EntityUid uid, AutoPostingChatComponent component) private void SetupEmoteTimer(EntityUid uid, AutoPostingChatComponent component) { - _emoteTimer.Interval = component.RandomIntervalEmote ? _random.Next(1000, 30001) : component.EmoteTimerRead; + _emoteTimer.Interval = component.RandomIntervalEmote ? _random.Next(component.MinRandomIntervalEmote*1000, component.MaxRandomIntervalEmote*1000) : component.EmoteTimerRead*1000; _emoteTimer.Elapsed += (sender, eventArgs) => { if (component.PostingMessageEmote != null) { - _chat.TrySendInGameICMessage(uid, component.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); + _chat.TrySendInGameICMessage(uid, _random.Pick(component.PostingMessageEmote), + InGameICChatType.Emote, ChatTransmitRange.Normal); } - _emoteTimer.Interval = component.RandomIntervalEmote ? _random.Next(1000, 30001) : component.EmoteTimerRead; + _emoteTimer.Interval = component.RandomIntervalEmote ? _random.Next(component.MinRandomIntervalEmote*1000, component.MaxRandomIntervalEmote*1000) : component.EmoteTimerRead*1000; }; _emoteTimer.Start(); diff --git a/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs index 32943b93147..f49c0904b00 100644 --- a/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs +++ b/Content.Shared/ADT/AutoPostingChat/AutoPostingChatComponent.cs @@ -13,6 +13,27 @@ public sealed partial class AutoPostingChatComponent : Component [DataField("randomIntervalSpeak"), ViewVariables(VVAccess.ReadWrite)] public bool RandomIntervalSpeak = false; + /// + /// The interval in milliseconds between automatic speech messages. + /// + [ViewVariables(VVAccess.ReadWrite)] + [DataField("maxRandomIntervalSpeak")] + public int MaxRandomIntervalSpeak = 30; + + /// + /// The interval in milliseconds between automatic speech messages. + /// + [ViewVariables(VVAccess.ReadWrite)] + [DataField("minRandomIntervalSpeak")] + public int MinRandomIntervalSpeak = 1; + + /// + /// The interval in milliseconds between automatic speech messages. + /// + [ViewVariables(VVAccess.ReadWrite)] + [DataField("speakTimer")] + public int SpeakTimerRead = 8; + /// /// Sets a random interval after each iteration of spoken emotions /// @@ -23,25 +44,32 @@ public sealed partial class AutoPostingChatComponent : Component /// The interval in milliseconds between automatic speech messages. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("speakTimer")] - public int SpeakTimerRead = 8000; + [DataField("maxRandomIntervalEmote")] + public int MaxRandomIntervalEmote = 30; + + /// + /// The interval in milliseconds between automatic speech messages. + /// + [ViewVariables(VVAccess.ReadWrite)] + [DataField("minRandomIntervalEmote")] + public int MinRandomIntervalEmote = 1; /// /// The interval in milliseconds between automatic emote messages. /// [ViewVariables(VVAccess.ReadWrite)] [DataField("emoteTimer")] - public int EmoteTimerRead = 9000; + public int EmoteTimerRead = 9; /// /// The message that will be automatically spoken by the entity. /// [DataField("speakMessage")] - public string? PostingMessageSpeak = ""; + public List PostingMessageSpeak = new List(); /// /// The message that will be automatically emotes by the entity. /// [DataField("emoteMessage")] - public string? PostingMessageEmote = ""; + public List PostingMessageEmote = new List(); }