mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using Content.Server.Chat.Managers;
|
||
using Content.Shared.Chat;
|
||
using Content.Shared.Damage;
|
||
using Content.Shared.HealthExaminable;
|
||
using Robust.Server.Player;
|
||
|
||
namespace Content.Server.HealthExaminable;
|
||
|
||
public sealed class HealthExaminableSystem : SharedHealthExaminableSystem
|
||
{
|
||
[Dependency] private readonly IChatManager _сhatManager = default!;
|
||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||
|
||
public override void Initialize()
|
||
{
|
||
base.Initialize();
|
||
|
||
SubscribeLocalEvent<HealthExaminableComponent, CheckHealthAlertEvent>(OnCheckHealthAlert);
|
||
}
|
||
|
||
private void OnCheckHealthAlert(EntityUid uid, HealthExaminableComponent component, CheckHealthAlertEvent args)
|
||
{
|
||
if (!TryComp(uid, out DamageableComponent? damageable)
|
||
|| !_playerManager.TryGetSessionByEntity(uid, out var session))
|
||
return;
|
||
|
||
var markup = Loc.GetString("health-alert-start")
|
||
+ "\n"
|
||
+ GetMarkup(uid, (uid, component), damageable).ToMarkup();
|
||
|
||
_сhatManager.ChatMessageToOne(
|
||
ChatChannel.Emotes,
|
||
markup,
|
||
markup,
|
||
EntityUid.Invalid,
|
||
false,
|
||
session.Channel);
|
||
}
|
||
}
|