mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
# Description The language PR was merged early and OH GOD I ALREADY REGRET IT This PR is intended to provide the missing refactors and address the issues that were missed due to the early merge. --- # TODO - [X] Introduced a polymorphic obfuscation property to the LanguagePrototype - now it supports more than just 2 hardcoded methods, and each method can be configured per-language. Currently there are 3 obfuscation methods: replacement (same as replacement accent), obuscation by syllables and obfuscation by phrases. - [X] Refactored the existing obfuscation methods to not be a big hardcoded mess. - [X] Updated the existing languages accordingly: animalistic languages are now less of an unreadable mess and include less syllables. Certain languages like binary and snake seriously benefit from that. - [X] Refactored the existing commands in response to the never-addressed review (it got lost among hundreds of others) - [X] Refactored the commands to be more user-friendly (you can now use the number of the language in saylang and languageselect which can allow using keybinds to switch between languages) - [X] Moved a lot of obfuscation-related stuff from server to shared. The actual obfuscation process, however, is still done on the server. That may or may not be subject to change, too. - [X] Refactored the entire process of resolution of entities' languages. Instead of raising an event every time it's required to learn what languages an entity knows, the lists of ALL languages available to the entity (including via translators) is stored in LanguageSpeakerComponent and only updated when necessary (e.g. when a translator gets toggled). The list of languages the entity knows on its own is now stored in LanguageKnowledgeComponent. - [X] Made handheld translators automatically change your current language when activated. - [X] Rewrote the translator implanter system, now using the real implants and implanters - [ ] Rebalance science stuff (translators are incredibly expensive for what they're worth) - [ ] Uhhh stuff --- <details><summary><h1>Media</h1></summary> <p> N/A for now </p> </details> --- # Changelog 🆑 - tweak: Translator implants are now proper implants that can be removed. - tweak: Animalistic languages should now look less messy. - fix: Hopefully fixed language menu desync and other issues. --------- Signed-off-by: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com>
76 lines
2.5 KiB
C#
76 lines
2.5 KiB
C#
using Content.Shared.Language;
|
|
using Content.Shared.Language.Events;
|
|
using Content.Shared.Language.Systems;
|
|
using Robust.Client;
|
|
|
|
namespace Content.Client.Language.Systems;
|
|
|
|
/// <summary>
|
|
/// Client-side language system.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Unlike the server, the client is not aware of other entities' languages; it's only notified about the entity that it posesses.
|
|
/// Due to that, this system stores such information in a static manner.
|
|
/// </remarks>
|
|
public sealed class LanguageSystem : SharedLanguageSystem
|
|
{
|
|
[Dependency] private readonly IBaseClient _client = default!;
|
|
|
|
/// <summary>
|
|
/// The current language of the entity currently possessed by the player.
|
|
/// </summary>
|
|
public string CurrentLanguage { get; private set; } = default!;
|
|
/// <summary>
|
|
/// The list of languages the currently possessed entity can speak.
|
|
/// </summary>
|
|
public List<string> SpokenLanguages { get; private set; } = new();
|
|
/// <summary>
|
|
/// The list of languages the currently possessed entity can understand.
|
|
/// </summary>
|
|
public List<string> UnderstoodLanguages { get; private set; } = new();
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeNetworkEvent<LanguagesUpdatedMessage>(OnLanguagesUpdated);
|
|
_client.RunLevelChanged += OnRunLevelChanged;
|
|
}
|
|
|
|
private void OnLanguagesUpdated(LanguagesUpdatedMessage message)
|
|
{
|
|
CurrentLanguage = message.CurrentLanguage;
|
|
SpokenLanguages = message.Spoken;
|
|
UnderstoodLanguages = message.Understood;
|
|
}
|
|
|
|
private void OnRunLevelChanged(object? sender, RunLevelChangedEventArgs args)
|
|
{
|
|
// Request an update when entering a game
|
|
if (args.NewLevel == ClientRunLevel.InGame)
|
|
RequestStateUpdate();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sends a network request to the server to update this system's state.
|
|
/// The server may ignore the said request if the player is not possessing an entity.
|
|
/// </summary>
|
|
public void RequestStateUpdate()
|
|
{
|
|
RaiseNetworkEvent(new RequestLanguagesMessage());
|
|
}
|
|
|
|
public void RequestSetLanguage(LanguagePrototype language)
|
|
{
|
|
if (language.ID == CurrentLanguage)
|
|
return;
|
|
|
|
RaiseNetworkEvent(new LanguagesSetMessage(language.ID));
|
|
|
|
// May cause some minor desync...
|
|
// So to reduce the probability of desync, we replicate the change locally too
|
|
if (SpokenLanguages.Contains(language.ID))
|
|
CurrentLanguage = language.ID;
|
|
}
|
|
}
|