feat: now when research is unlocked in console, approver of reasearch is radio-ed too (#31170)

* feat: now when research is unlocked in console, approver of reasearch is radio-ed too

* refactor: now most of events that require actor name to be radio-ed or logged use TryGetIdentityShortInfoEvent which is subscibed by id-card system and borg system (to work for both carbon and synthetic life-forms)

* refactor: moved TryGetIdentityShortInfoEvent on id card system to shared, fixed cargo cent-com-originated orders

* remove unused check

* refactor: decoupled systems from IdCardSystem (those that are not dependent on it anymore)

* refactor: removed unuseed usings

* feat: emagged cargo/research consoles wont radio messages on buy/research confirm anymore

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
This commit is contained in:
Fildrance
2024-09-03 16:01:38 +03:00
committed by GitHub
parent 894d4980f5
commit 6380a9adca
13 changed files with 141 additions and 50 deletions

View File

@@ -1,7 +1,9 @@
using System.Globalization;
using Content.Shared.Access.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Hands.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.Inventory;
using Content.Shared.PDA;
using Content.Shared.Roles;
@@ -20,7 +22,9 @@ public abstract class SharedIdCardSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<IdCardComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<TryGetIdentityShortInfoEvent>(OnTryGetIdentityShortInfo);
}
private void OnMapInit(EntityUid uid, IdCardComponent id, MapInitEvent args)
@@ -28,6 +32,23 @@ public abstract class SharedIdCardSystem : EntitySystem
UpdateEntityName(uid, id);
}
private void OnTryGetIdentityShortInfo(TryGetIdentityShortInfoEvent ev)
{
if (ev.Handled)
{
return;
}
string? title = null;
if (TryFindIdCard(ev.ForActor, out var idCard) && !(ev.RequestForAccessLogging && idCard.Comp.BypassLogging))
{
title = ExtractFullTitle(idCard);
}
ev.Title = title;
ev.Handled = true;
}
/// <summary>
/// Attempt to find an ID card on an entity. This will look in the entity itself, in the entity's hands, and
/// in the entity's inventory.
@@ -214,4 +235,10 @@ public abstract class SharedIdCardSystem : EntitySystem
("jobSuffix", jobSuffix));
_metaSystem.SetEntityName(uid, val);
}
private static string ExtractFullTitle(IdCardComponent idCardComponent)
{
return $"{idCardComponent.FullName} ({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(idCardComponent.JobTitle ?? string.Empty)})"
.Trim();
}
}