-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Clicking on Health Alerty Now Displays Health State (#1139)
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description I don't understand why it hasn't been done before tbf. https://github.com/user-attachments/assets/6ea2a3eb-80ce-4905-b546-7b8902308533 --- # Changelog :cl: - add: Clicking on health alert now will print message in chat, displaying your health state. --------- Signed-off-by: Remuchi <[email protected]>
- Loading branch information
Showing
5 changed files
with
61 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IChatManager>(); | ||
var entityManager = IoCManager.Resolve<IEntityManager>(); | ||
var playerManager = IoCManager.Resolve<IPlayerManager>(); | ||
|
||
var healthExaminableSystem = entityManager.System<HealthExaminableSystem>(); | ||
|
||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Resources/Locale/en-US/health-examinable/health-examinable-comp.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] |
2 changes: 1 addition & 1 deletion
2
Resources/Locale/en-US/health-examinable/health-examinable-silicon.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters