mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
Resolves https://github.com/Simple-Station/Einstein-Engines/issues/37 # Description This PR adds languages. Every entity who can speak now speaks a specific language (or Universal, for entities that are not supposed to speak, which is understood by everyone). Other entities who do not understand this language will see gibberish (it's possible to learn how certain induvidual words are spelled. But the spelling changes between rounds). This means that certain creatures, like xenos, cats, vulps, can communicate within their species in their own languages. Similarly, it means that xenos, cats and other things cannot understand GalacticCommon speakers without a translator or cognization. An entity may be able to speak multiple languages, or understand a language but be unable to speak it. Thi PR was orignally made for Frontier but is now being ported and will be maintain here. Orignal PR: https://github.com/new-frontiers-14/frontier-station-14/pull/671 This PR was made orignally by Mnemotechnician and FoxxoTrystan. --- # TODO - [x] Language System. (Check Frontier PR for all the compleated todo list) - [x] Port PR from Frontier. - [x] QOL Changes. - [x] Missing Default Languages. (Missing default langauges for some roundstart species) - [x] Animals Languages. --- <details><summary><h1>Media</h1></summary> <p>    </p> </details> --- # Changelog 🆑 FoxxoTrystan / Mnemotechnician - add: All species can now bring their own cultures and languages --------- Signed-off-by: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com> Signed-off-by: FoxxoTrystan <45297731+FoxxoTrystan@users.noreply.github.com> Co-authored-by: fox <daytimer253@gmail.com> Co-authored-by: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com> Co-authored-by: Pspritechologist <81725545+Pspritechologist@users.noreply.github.com> Co-authored-by: Lincoln McQueen <lincoln.mcqueen@gmail.com> Co-authored-by: Arkyfloof <Marvinlinke08@gmail.com> Co-authored-by: reese1243 <ber23027@byui.edu> Co-authored-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: Eagle-0 <114363363+Eagle-0@users.noreply.github.com> Co-authored-by: BlitzDev <145472107+Reese1243@users.noreply.github.com> Co-authored-by: Arkyfloof <161242062+Arkyfloof@users.noreply.github.com> Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com> Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using Content.Server.Mind;
|
|
using Content.Shared.Language;
|
|
using Content.Shared.Language.Events;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Mind.Components;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Server.Language;
|
|
|
|
/// <summary>
|
|
/// LanguageSystem Networking
|
|
/// This is used to update client state when mind change entity.
|
|
/// </summary>
|
|
|
|
public sealed partial class LanguageSystem
|
|
{
|
|
[Dependency] private readonly MindSystem _mind = default!;
|
|
|
|
|
|
public void InitializeNet()
|
|
{
|
|
// Refresh the client's state when its mind hops to a different entity
|
|
SubscribeLocalEvent<MindContainerComponent, MindAddedMessage>((uid, _, _) => SendLanguageStateToClient(uid));
|
|
SubscribeLocalEvent<MindComponent, MindGotRemovedEvent>((_, _, args) =>
|
|
{
|
|
if (args.Mind.Comp.Session != null)
|
|
SendLanguageStateToClient(args.Mind.Comp.Session);
|
|
});
|
|
|
|
SubscribeLocalEvent<LanguageSpeakerComponent, LanguagesUpdateEvent>((uid, comp, _) => SendLanguageStateToClient(uid, comp));
|
|
SubscribeNetworkEvent<RequestLanguagesMessage>((_, session) => SendLanguageStateToClient(session.SenderSession));
|
|
}
|
|
|
|
|
|
private void SendLanguageStateToClient(EntityUid uid, LanguageSpeakerComponent? comp = null)
|
|
{
|
|
// Try to find a mind inside the entity and notify its session
|
|
if (!_mind.TryGetMind(uid, out _, out var mindComp) || mindComp.Session == null)
|
|
return;
|
|
|
|
SendLanguageStateToClient(uid, mindComp.Session, comp);
|
|
}
|
|
|
|
private void SendLanguageStateToClient(ICommonSession session, LanguageSpeakerComponent? comp = null)
|
|
{
|
|
// Try to find an entity associated with the session and resolve the languages from it
|
|
if (session.AttachedEntity is not { Valid: true } entity)
|
|
return;
|
|
|
|
SendLanguageStateToClient(entity, session, comp);
|
|
}
|
|
|
|
private void SendLanguageStateToClient(EntityUid uid, ICommonSession session, LanguageSpeakerComponent? component = null)
|
|
{
|
|
var langs = GetLanguages(uid, component);
|
|
var message = new LanguagesUpdatedMessage(langs.CurrentLanguage, langs.SpokenLanguages, langs.UnderstoodLanguages);
|
|
RaiseNetworkEvent(message, session);
|
|
}
|
|
}
|