Skip to content

Commit

Permalink
Должности в гарнитуре.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrimeMoot authored Jul 19, 2024
1 parent 7e3f3fa commit 7cb9f3c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
38 changes: 37 additions & 1 deletion Content.Server/Radio/EntitySystems/RadioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
using Content.Shared.Radio;
using Content.Shared.Radio.Components;
using Content.Shared.Speech;
using Content.Shared.Access.Components;
using Content.Shared.Humanoid;
using Content.Shared.Inventory;
using Content.Shared.PDA;
using System.Globalization;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Player;
Expand All @@ -29,6 +34,7 @@ public sealed class RadioSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;

// set used to prevent radio feedback loops.
private readonly HashSet<string> _messages = new();
Expand Down Expand Up @@ -84,6 +90,12 @@ public void SendRadioMessage(EntityUid messageSource, string message, RadioChann

name = FormattedMessage.EscapeText(name);

var formattedName = name;
if (TryComp<HumanoidAppearanceComponent>(messageSource, out var humanoidComp))
{
formattedName = $"[color={humanoidComp.SpeakerColor.ToHex()}]{GetIdCardName(messageSource)}{name}[/color]";

Check failure on line 96 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

'HumanoidAppearanceComponent' does not contain a definition for 'SpeakerColor' and no accessible extension method 'SpeakerColor' accepting a first argument of type 'HumanoidAppearanceComponent' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

'HumanoidAppearanceComponent' does not contain a definition for 'SpeakerColor' and no accessible extension method 'SpeakerColor' accepting a first argument of type 'HumanoidAppearanceComponent' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'HumanoidAppearanceComponent' does not contain a definition for 'SpeakerColor' and no accessible extension method 'SpeakerColor' accepting a first argument of type 'HumanoidAppearanceComponent' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'HumanoidAppearanceComponent' does not contain a definition for 'SpeakerColor' and no accessible extension method 'SpeakerColor' accepting a first argument of type 'HumanoidAppearanceComponent' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'HumanoidAppearanceComponent' does not contain a definition for 'SpeakerColor' and no accessible extension method 'SpeakerColor' accepting a first argument of type 'HumanoidAppearanceComponent' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'HumanoidAppearanceComponent' does not contain a definition for 'SpeakerColor' and no accessible extension method 'SpeakerColor' accepting a first argument of type 'HumanoidAppearanceComponent' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

'HumanoidAppearanceComponent' does not contain a definition for 'SpeakerColor' and no accessible extension method 'SpeakerColor' accepting a first argument of type 'HumanoidAppearanceComponent' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

'HumanoidAppearanceComponent' does not contain a definition for 'SpeakerColor' and no accessible extension method 'SpeakerColor' accepting a first argument of type 'HumanoidAppearanceComponent' could be found (are you missing a using directive or an assembly reference?)
}

SpeechVerbPrototype speech;
if (mask != null
&& mask.Enabled
Expand All @@ -105,7 +117,7 @@ public void SendRadioMessage(EntityUid messageSource, string message, RadioChann
("fontSize", speech.FontSize),
("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
("channel", $"\\[{channel.LocalizedName}\\]"),
("name", name),
("name", formattedName),
("message", content));

// most radios are relayed to chat, so lets parse the chat message beforehand
Expand Down Expand Up @@ -165,6 +177,30 @@ public void SendRadioMessage(EntityUid messageSource, string message, RadioChann
_messages.Remove(message);
}

private string GetIdCardName(EntityUid senderUid)
{
var idCardTitle = Loc.GetString("chat-radio-no-id");

if (_inventorySystem.TryGetSlotEntity(senderUid, "id", out var idUid))
{
if (EntityManager.TryGetComponent(idUid, out PdaComponent? pda) && pda.ContainedId is not null)
{
// PDA
idCardTitle = pda.ContainedId.JobTitle ?? idCardTitle;

Check failure on line 189 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

'EntityUid?' does not contain a definition for 'JobTitle' and no accessible extension method 'JobTitle' accepting a first argument of type 'EntityUid?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 189 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

'EntityUid?' does not contain a definition for 'JobTitle' and no accessible extension method 'JobTitle' accepting a first argument of type 'EntityUid?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 189 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'EntityUid?' does not contain a definition for 'JobTitle' and no accessible extension method 'JobTitle' accepting a first argument of type 'EntityUid?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 189 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'EntityUid?' does not contain a definition for 'JobTitle' and no accessible extension method 'JobTitle' accepting a first argument of type 'EntityUid?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 189 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'EntityUid?' does not contain a definition for 'JobTitle' and no accessible extension method 'JobTitle' accepting a first argument of type 'EntityUid?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 189 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'EntityUid?' does not contain a definition for 'JobTitle' and no accessible extension method 'JobTitle' accepting a first argument of type 'EntityUid?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 189 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

'EntityUid?' does not contain a definition for 'JobTitle' and no accessible extension method 'JobTitle' accepting a first argument of type 'EntityUid?' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 189 in Content.Server/Radio/EntitySystems/RadioSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

'EntityUid?' does not contain a definition for 'JobTitle' and no accessible extension method 'JobTitle' accepting a first argument of type 'EntityUid?' could be found (are you missing a using directive or an assembly reference?)
}
else if (EntityManager.TryGetComponent(idUid, out IdCardComponent? id))
{
// ID Card
idCardTitle = id.JobTitle ?? idCardTitle;
}
}

var textInfo = CultureInfo.CurrentCulture.TextInfo;
idCardTitle = textInfo.ToTitleCase(idCardTitle);

return $"\\[{idCardTitle}\\] ";
}

/// <inheritdoc cref="TelecomServerComponent"/>
private bool HasActiveServer(MapId mapId, string channelId)
{
Expand Down
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/headset/headset-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ chat-radio-freelance = Freelance
# not headset but whatever
chat-radio-handheld = Handheld
chat-radio-binary = Binary
chat-radio-no-id = No ID
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/headset/headset-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ chat-radio-freelance = Фриланс
# not headset but whatever
chat-radio-handheld = Портативный
chat-radio-binary = Двоичный
chat-radio-no-id = Без ID

0 comments on commit 7cb9f3c

Please sign in to comment.