diff --git a/Content.Server/ADT/AutoPostingChat/AutoEmotePostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoEmotePostingChatSystem.cs new file mode 100644 index 00000000000..1533eeafb79 --- /dev/null +++ b/Content.Server/ADT/AutoPostingChat/AutoEmotePostingChatSystem.cs @@ -0,0 +1,51 @@ +using Content.Shared.Mobs; +using Content.Server.Chat.Systems; +using Content.Shared.ADT.AutoPostingChat; +using Robust.Shared.Timing; +using Robust.Shared.Random; +public sealed class AutoEmotePostingChatSystem : EntitySystem +{ + [Dependency] private readonly ChatSystem _chat = default!; + [Dependency] private readonly IGameTiming _time = default!; + [Dependency] private readonly IRobustRandom _random = default!; + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnMobState); + } + /// + /// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning. + /// + private void OnMobState(EntityUid uid, AutoEmotePostingChatComponent component, MobStateChangedEvent args) + { + if (args.NewMobState == MobState.Dead) + { + RemComp(uid); + } + } + public override void Update(float frameTime) + { + base.Update(frameTime); + + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var comp)) + { + if (_time.CurTime >= comp.NextSecond) + { + var delay = comp.EmoteTimerRead; + + if (comp.PostingMessageEmote != null) + { + _chat.TrySendInGameICMessage(uid, comp.PostingMessageEmote, InGameICChatType.Emote, ChatTransmitRange.Normal); + } + + if (comp.RandomIntervalEmote) + { + delay = _random.Next(comp.IntervalRandomEmoteMin, comp.IntervalRandomEmoteMax); + } + + comp.NextSecond = _time.CurTime + TimeSpan.FromSeconds(delay); + } + } + } +} diff --git a/Content.Server/ADT/AutoPostingChat/AutoSpeakPostingChatSystem.cs b/Content.Server/ADT/AutoPostingChat/AutoSpeakPostingChatSystem.cs new file mode 100644 index 00000000000..a73ab1556f0 --- /dev/null +++ b/Content.Server/ADT/AutoPostingChat/AutoSpeakPostingChatSystem.cs @@ -0,0 +1,51 @@ +using Content.Shared.Mobs; +using Content.Server.Chat.Systems; +using Content.Shared.ADT.AutoPostingChat; +using Robust.Shared.Timing; +using Robust.Shared.Random; +public sealed class AutoSpeakPostingChatSystem : EntitySystem +{ + [Dependency] private readonly ChatSystem _chat = default!; + [Dependency] private readonly IGameTiming _time = default!; + [Dependency] private readonly IRobustRandom _random = default!; + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnMobState); + } + /// + /// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning. + /// + private void OnMobState(EntityUid uid, AutoSpeakPostingChatComponent component, MobStateChangedEvent args) + { + if (args.NewMobState == MobState.Dead) + { + RemComp(uid); + } + } + public override void Update(float frameTime) + { + base.Update(frameTime); + + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var comp)) + { + if (_time.CurTime >= comp.NextSecond) + { + var delay = comp.SpeakTimerRead; + + if (comp.PostingMessageSpeak != null) + { + _chat.TrySendInGameICMessage(uid, comp.PostingMessageSpeak, InGameICChatType.Speak, ChatTransmitRange.Normal); + } + + if (comp.RandomIntervalSpeak) + { + delay = _random.Next(comp.IntervalRandomSpeakMin, comp.IntervalRandomSpeakMax); + } + + comp.NextSecond = _time.CurTime + TimeSpan.FromSeconds(delay); + } + } + } +} diff --git a/Content.Shared/ADT/AutoPostingChat/AutoEmotePostingChatComponent.cs b/Content.Shared/ADT/AutoPostingChat/AutoEmotePostingChatComponent.cs new file mode 100644 index 00000000000..68882783885 --- /dev/null +++ b/Content.Shared/ADT/AutoPostingChat/AutoEmotePostingChatComponent.cs @@ -0,0 +1,28 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.ADT.AutoPostingChat; + +[RegisterComponent] +[NetworkedComponent] +public sealed partial class AutoEmotePostingChatComponent : Component +{ + + public TimeSpan NextSecond = TimeSpan.Zero; + + [DataField("emoteTimer"), ViewVariables(VVAccess.ReadWrite)] + public int EmoteTimerRead = 9; + + [DataField("emoteMessage")] + public string? PostingMessageEmote = "Кхе"; + + [DataField("randomIntervalEmote"), ViewVariables(VVAccess.ReadWrite)] + public bool RandomIntervalEmote = false; + + [DataField("max"), ViewVariables(VVAccess.ReadWrite)] + public int IntervalRandomEmoteMax = 30; + + [DataField("min"), ViewVariables(VVAccess.ReadWrite)] + public int IntervalRandomEmoteMin = 2; + + +} diff --git a/Content.Shared/ADT/AutoPostingChat/AutoSpeakPostingChatComponent.cs b/Content.Shared/ADT/AutoPostingChat/AutoSpeakPostingChatComponent.cs new file mode 100644 index 00000000000..90e6fd11c1d --- /dev/null +++ b/Content.Shared/ADT/AutoPostingChat/AutoSpeakPostingChatComponent.cs @@ -0,0 +1,29 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.ADT.AutoPostingChat; + +[RegisterComponent] +[NetworkedComponent] +public sealed partial class AutoSpeakPostingChatComponent : Component +{ + + public TimeSpan NextSecond = TimeSpan.Zero; + + [DataField("speakTimer"), ViewVariables(VVAccess.ReadWrite)] + public int SpeakTimerRead = 10; + + [DataField("speakMessage")] + public string? PostingMessageSpeak = "Вульп-вульп!"; + + [DataField("randomIntervalSpeak"), ViewVariables(VVAccess.ReadWrite)] + public bool RandomIntervalSpeak = false; + + [DataField("max"), ViewVariables(VVAccess.ReadWrite)] + public int IntervalRandomSpeakMax = 30; + + [DataField("min"), ViewVariables(VVAccess.ReadWrite)] + public int IntervalRandomSpeakMin = 2; + + + +}