Files
wwdpublic/Content.Shared/Language/Systems/SharedTranslatorSystem.cs
Mnemotechnican 6084740437 Foreigner Traits (#525)
# Description
Adds two negative traits, foreigner and its light version. Both of them
make you unable to speak galactic common and give you a translator that
lets you speak/understand GC, and also requires you to know one of the
non-GC languages your entity normally speaks in order to work. The
translator starts with a high-capacity power cell to compensate for the
usual scarcity of publicly accessible chargers on most stations.

The light version of the trait only makes you unable to speak GC. The
heavy version also makes you unable to understand others when they speak
it.

This PR also makes you able to wear translator in the neck slot for
convenience and transparency, and rewamps the examination menu of
translators to provide more useful info.

One little known issue (as seen in the screenshots below) is that, since
the system chooses the first language in the list of languages your
entity can speak, it can sometimes pick wrong if your species speaks
more than two language, but it won't prevent you from using the
translator normally.

Also, the name of the light version of the trait is subject to change. I
just couldn't think of anything more creative for it.

# Why

Although supposedly trystan or others have a language menu in mind, it's
still not even being worked on yet. At the same time, I've already seen
some people roleplay as though their characters do not speak galactic
common.

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


![image](https://github.com/Simple-Station/Einstein-Engines/assets/69920617/42984284-3a70-40bb-ad48-b11218cd5c5b)


![image](https://github.com/Simple-Station/Einstein-Engines/assets/69920617/f3d26cef-a908-49e7-84e0-cb50d5d98c0d)


![image](https://github.com/Simple-Station/Einstein-Engines/assets/69920617/6f44b3cc-5906-402b-ae5c-a3f0ad743bc6)


![image](https://github.com/Simple-Station/Einstein-Engines/assets/69920617/4edfe7ce-1633-4e6a-94ca-5db0dff88eb0)


![image](https://github.com/Simple-Station/Einstein-Engines/assets/69920617/ec5b3da0-b400-41f3-90c1-e5dc6b5af7c5)

</p>
</details>

---

# Changelog

🆑
- add: Added two new foreigner traits that make your character unable to
speak Galactic Common and give you a translator instead.
- tweak: Translators can now be equipped in the neck slot and display
useful info when examined.
2024-07-11 21:19:09 -04:00

45 lines
1.8 KiB
C#

using System.Linq;
using Content.Shared.Examine;
using Content.Shared.Toggleable;
using Content.Shared.Language.Components.Translators;
namespace Content.Shared.Language.Systems;
public abstract class SharedTranslatorSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HandheldTranslatorComponent, ExaminedEvent>(OnExamined);
}
private void OnExamined(EntityUid uid, HandheldTranslatorComponent component, ExaminedEvent args)
{
var understoodLanguageNames = component.UnderstoodLanguages
.Select(it => Loc.GetString($"language-{it}-name"));
var spokenLanguageNames = component.SpokenLanguages
.Select(it => Loc.GetString($"language-{it}-name"));
var requiredLanguageNames = component.RequiredLanguages
.Select(it => Loc.GetString($"language-{it}-name"));
args.PushMarkup(Loc.GetString("translator-examined-langs-understood", ("languages", string.Join(", ", understoodLanguageNames))));
args.PushMarkup(Loc.GetString("translator-examined-langs-spoken", ("languages", string.Join(", ", spokenLanguageNames))));
args.PushMarkup(Loc.GetString(component.RequiresAllLanguages ? "translator-examined-requires-all" : "translator-examined-requires-any",
("languages", string.Join(", ", requiredLanguageNames))));
args.PushMarkup(Loc.GetString(component.Enabled ? "translator-examined-enabled" : "translator-examined-disabled"));
}
protected void OnAppearanceChange(EntityUid translator, HandheldTranslatorComponent? comp = null)
{
if (comp == null && !TryComp(translator, out comp))
return;
_appearance.SetData(translator, ToggleVisuals.Toggled, comp.Enabled);
}
}