diff --git a/Content.Server/Alert/Click/CheckHealth.cs b/Content.Server/Alert/Click/CheckHealth.cs new file mode 100644 index 00000000000..31beff69c29 --- /dev/null +++ b/Content.Server/Alert/Click/CheckHealth.cs @@ -0,0 +1,44 @@ +using Content.Server.Chat.Managers; +using Content.Shared.Alert; +using Content.Shared.Chat; +using Content.Shared.Damage; +using Content.Shared.HealthExaminable; +using JetBrains.Annotations; +using Robust.Server.Player; +using Robust.Shared.Player; + +namespace Content.Server.Alert.Click; + +[UsedImplicitly] +[DataDefinition] +public sealed partial class CheckHealth : IAlertClick +{ + public void AlertClicked(EntityUid player) + { + var chatManager = IoCManager.Resolve(); + var entityManager = IoCManager.Resolve(); + var playerManager = IoCManager.Resolve(); + + var healthExaminableSystem = entityManager.System(); + + if (!entityManager.TryGetComponent(player, out HealthExaminableComponent? healthExaminable) || + !entityManager.TryGetComponent(player, out DamageableComponent? damageable) || + !playerManager.TryGetSessionByEntity(player, out var session)) + return; + + var baseMsg = Loc.GetString("health-alert-start"); + SendMessage(chatManager, baseMsg, session); + var markup = healthExaminableSystem.GetMarkup(player, (player, healthExaminable), damageable).ToMarkup(); + SendMessage(chatManager, markup, session); + } + + private static void SendMessage(IChatManager chatManager, string msg, ICommonSession session) + { + chatManager.ChatMessageToOne(ChatChannel.Emotes, + msg, + msg, + EntityUid.Invalid, + false, + session.Channel); + } +} diff --git a/Content.Shared/HealthExaminable/HealthExaminableSystem.cs b/Content.Shared/HealthExaminable/HealthExaminableSystem.cs index 39addfc9410..091176a3cb1 100644 --- a/Content.Shared/HealthExaminable/HealthExaminableSystem.cs +++ b/Content.Shared/HealthExaminable/HealthExaminableSystem.cs @@ -30,30 +30,33 @@ private void OnGetExamineVerbs(EntityUid uid, HealthExaminableComponent componen var detailsRange = _examineSystem.IsInDetailsRange(args.User, uid); - var verb = new ExamineVerb() + var verb = new ExamineVerb { Act = () => { - FormattedMessage markup; - if (uid == args.User - && TryComp(uid, out var selfAware)) - markup = CreateMarkupSelfAware(uid, selfAware, component, damage); - else - markup = CreateMarkup(uid, component, damage); - + var markup = GetMarkup(args.User, (uid, component), damage); _examineSystem.SendExamineTooltip(args.User, uid, markup, false, false); }, Text = Loc.GetString("health-examinable-verb-text"), Category = VerbCategory.Examine, Disabled = !detailsRange, Message = detailsRange ? null : Loc.GetString("health-examinable-verb-disabled"), - Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")) + Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/rejuvenate.svg.192dpi.png")) }; args.Verbs.Add(verb); } - public FormattedMessage CreateMarkup(EntityUid uid, HealthExaminableComponent component, DamageableComponent damage) + public FormattedMessage GetMarkup(EntityUid examiner, + Entity examinable, + DamageableComponent damageable) + { + return examiner == examinable.Owner && TryComp(examinable, out var selfAware) + ? CreateMarkupSelfAware(examinable, selfAware, examinable.Comp, damageable) + : CreateMarkup(examinable, examinable.Comp, damageable); + } + + private FormattedMessage CreateMarkup(EntityUid uid, HealthExaminableComponent component, DamageableComponent damage) { var msg = new FormattedMessage(); diff --git a/Resources/Locale/en-US/health-examinable/health-examinable-comp.ftl b/Resources/Locale/en-US/health-examinable/health-examinable-comp.ftl index af31837ab84..60204eb2bd3 100644 --- a/Resources/Locale/en-US/health-examinable/health-examinable-comp.ftl +++ b/Resources/Locale/en-US/health-examinable/health-examinable-comp.ftl @@ -1,2 +1,4 @@ health-examinable-verb-text = Health health-examinable-verb-disabled = Perform a basic health examination in close range. + +health-alert-start = [font size=12][color=green]Health:[/color][/font] diff --git a/Resources/Locale/en-US/health-examinable/health-examinable-silicon.ftl b/Resources/Locale/en-US/health-examinable/health-examinable-silicon.ftl index 03eaf07a3b7..1608d8511d1 100644 --- a/Resources/Locale/en-US/health-examinable/health-examinable-silicon.ftl +++ b/Resources/Locale/en-US/health-examinable/health-examinable-silicon.ftl @@ -1,4 +1,4 @@ -health-examinable-silicon-none = There is no obvious damage to be seen. +health-examinable-silicon-none = [color=green]There is no obvious damage to be seen.[/color] health-examinable-silicon-Blunt-25 = [color=red]{ CAPITALIZE(SUBJECT($target)) } { CONJUGATE-HAVE($target) } minor dents on { POSS-ADJ($target) } chassis.[/color] health-examinable-silicon-Blunt-50 = [color=crimson]{ CAPITALIZE(POSS-ADJ($target)) } chassis is severely dented![/color] diff --git a/Resources/Prototypes/Alerts/alerts.yml b/Resources/Prototypes/Alerts/alerts.yml index bb0c47f48fb..e32eea3cc93 100644 --- a/Resources/Prototypes/Alerts/alerts.yml +++ b/Resources/Prototypes/Alerts/alerts.yml @@ -192,6 +192,7 @@ - type: alert id: HumanHealth category: Health + onClick: !type:CheckHealth { } icons: - sprite: /Textures/Interface/Alerts/human_alive.rsi state: health0