-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66231d8
commit d56c374
Showing
2 changed files
with
43 additions
and
13 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
Content.Server/ADT/AutoPostingChat/AutoEmotePostingChatSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Content.Shared.Mobs; | ||
using Content.Server.Chat.Systems; | ||
using Content.Shared.ADT.AutoPostingChat; | ||
using Robust.Shared.Timing; | ||
public sealed class AutoEmotePostingChatSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ChatSystem _chat = default!; | ||
[Dependency] private readonly IGameTiming _time = 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 || component == null) | ||
{ | ||
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) | ||
{ | ||
if (comp.PostingMessageEmote != null) | ||
{ | ||
_chat.TrySendInGameICMessage(uid, comp.PostingMessageEmote, InGameICChatType.Speak, ChatTransmitRange.Normal); | ||
} | ||
|
||
comp.NextSecond = _time.CurTime + TimeSpan.FromSeconds(comp.EmoteTimerRead); | ||
} | ||
} | ||
} | ||
} |
14 changes: 1 addition & 13 deletions
14
Content.Server/ADT/AutoPostingChat/AutoSpeakPostingChatSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters