-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- ЭТО ШАБЛОН ВАШЕГО PULL REQUEST. Текст между стрелками - это комментарии - они не будут видны в PR. --> ## Описание PR <!-- Ниже опишите ваш Pull Request. Что он изменяет? На что еще это может повлиять? Постарайтесь описать все внесённые вами изменения! --> Вешаем один из этих компонентов на сущность и она начинает постить в зависимости от компоненты или эмоуты или слова **Проверки** <!-- Выполнение всех следующих действий, если это приемлемо для вида изменений сильно ускорит разбор вашего PR --> - [ ] PR полностью завершён и мне не нужна помощь чтобы его закончить. - [x] Я внимательно просмотрел все свои изменения и багов в них не нашёл. - [x] Я запускал локальный сервер со своими изменениями и всё протестировал. - [ ] Я добавил скриншот/видео демонстрации PR в игре, **или** этот PR этого не требует. **Изменения** no cl, no fun
- Loading branch information
1 parent
1d81479
commit ad1f542
Showing
4 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
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,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
51
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
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); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
Content.Shared/ADT/AutoPostingChat/AutoEmotePostingChatComponent.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,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; | ||
|
||
|
||
} |
29 changes: 29 additions & 0 deletions
29
Content.Shared/ADT/AutoPostingChat/AutoSpeakPostingChatComponent.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,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; | ||
|
||
|
||
|
||
} |