Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SayPosting #220

Merged
merged 14 commits into from
Sep 1, 2024
51 changes: 51 additions & 0 deletions Content.Server/ADT/AutoPostingChat/AutoEmotePostingChatSystem.cs
Original file line number Diff line number Diff line change
@@ -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<AutoEmotePostingChatComponent, MobStateChangedEvent>(OnMobState);
}
/// <summary>
/// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning.
/// </summary>
private void OnMobState(EntityUid uid, AutoEmotePostingChatComponent component, MobStateChangedEvent args)
{
if (args.NewMobState == MobState.Dead)
{
RemComp<AutoEmotePostingChatComponent>(uid);
}
}
public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<AutoEmotePostingChatComponent>();
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);
}
}
}
}
51 changes: 51 additions & 0 deletions Content.Server/ADT/AutoPostingChat/AutoSpeakPostingChatSystem.cs
Original file line number Diff line number Diff line change
@@ -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<AutoSpeakPostingChatComponent, MobStateChangedEvent>(OnMobState);
}
/// <summary>
/// On death removes active comps and gives genetic damage to prevent cloning, reduce this to allow cloning.
/// </summary>
private void OnMobState(EntityUid uid, AutoSpeakPostingChatComponent component, MobStateChangedEvent args)
{
if (args.NewMobState == MobState.Dead)
{
RemComp<AutoSpeakPostingChatComponent>(uid);
}
}
public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<AutoSpeakPostingChatComponent>();
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);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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;


}
Original file line number Diff line number Diff line change
@@ -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;



}
Loading