Files
wwdpublic/Content.Server/Mobs/CritMobActionsSystem.cs
Mnemotechnican 92dcd724d4 Refactor Sign Languages and Language Markers (#575)
# Description
This refactors #510 and #553. #553 specifically was reverted and
re-implemented from scratch. As a consequence to all of this, the chat
system was refactored a bit too, hopefully for the best.

Changes:
- InGameICChatType, InGameOOCChatType, ChatTransmitRange were all moved
to shared and made serializable
- Added a method to wrap whisper messages to reduce code duplication in
chat system
- Both WrapPublicMethod and WrapWhisperMessage call the same generic
WrapMessage method, which allows to add speech verbs to whispers and
more. That method is also fully responsible for adding language markers
and deducing speech verbs now.
- Everything related to speech was moved out of LanguagePrototype and
into SpeechOverrideInfo. LanguagePrototype now holds an instance of
that.
- Added AllowRadio, RequireSpeech, ChatTypeOverride,
SpeechVerbOverrides, MessageWrapOverrides to SpeechOverrideInfo, all of
which are used in implementing the sign language.
- Suffered a lot

# TODO
- [X] Cry
- [X] Fix the sign language not displaying properly over the character.
- [X] Find a way to circumvent being unable to speak??

<details><summary><h1>Media</h1></summary><p>


![image](https://github.com/user-attachments/assets/845ec5d3-20aa-4786-bdc8-c39c80e0a4a3)

See below

</p></details>

# Changelog
No cl no fun

---------

Signed-off-by: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com>
Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com>
2024-07-26 13:11:42 -07:00

87 lines
3.0 KiB
C#

using Content.Server.Administration;
using Content.Server.Chat.Systems;
using Content.Server.Popups;
using Content.Server.Speech.Muting;
using Content.Shared.Chat;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Server.Console;
using Robust.Shared.Player;
using Content.Shared.Speech.Muting;
namespace Content.Server.Mobs;
/// <summary>
/// Handles performing crit-specific actions.
/// </summary>
public sealed class CritMobActionsSystem : EntitySystem
{
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly DeathgaspSystem _deathgasp = default!;
[Dependency] private readonly IServerConsoleHost _host = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly QuickDialogSystem _quickDialog = default!;
private const int MaxLastWordsLength = 30;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MobStateActionsComponent, CritSuccumbEvent>(OnSuccumb);
SubscribeLocalEvent<MobStateActionsComponent, CritFakeDeathEvent>(OnFakeDeath);
SubscribeLocalEvent<MobStateActionsComponent, CritLastWordsEvent>(OnLastWords);
}
private void OnSuccumb(EntityUid uid, MobStateActionsComponent component, CritSuccumbEvent args)
{
if (!TryComp<ActorComponent>(uid, out var actor) || !_mobState.IsCritical(uid))
return;
_host.ExecuteCommand(actor.PlayerSession, "ghost");
args.Handled = true;
}
private void OnFakeDeath(EntityUid uid, MobStateActionsComponent component, CritFakeDeathEvent args)
{
if (!_mobState.IsCritical(uid))
return;
if (HasComp<MutedComponent>(uid))
{
_popupSystem.PopupEntity(Loc.GetString("fake-death-muted"), uid, uid);
return;
}
args.Handled = _deathgasp.Deathgasp(uid);
}
private void OnLastWords(EntityUid uid, MobStateActionsComponent component, CritLastWordsEvent args)
{
if (!TryComp<ActorComponent>(uid, out var actor))
return;
_quickDialog.OpenDialog(actor.PlayerSession, Loc.GetString("action-name-crit-last-words"), "",
(string lastWords) =>
{
// Intentionally does not check for muteness
if (actor.PlayerSession.AttachedEntity != uid
|| !_mobState.IsCritical(uid))
return;
if (lastWords.Length > MaxLastWordsLength)
{
lastWords = lastWords.Substring(0, MaxLastWordsLength);
}
lastWords += "...";
_chat.TrySendInGameICMessage(uid, lastWords, InGameICChatType.Whisper, ChatTransmitRange.Normal, checkRadioPrefix: false, ignoreActionBlocker: true);
_host.ExecuteCommand(actor.PlayerSession, "ghost");
});
args.Handled = true;
}
}