45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using Content.Shared.Examine;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Verbs;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Server.DetailExaminable
|
|
{
|
|
public sealed class DetailExaminableSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly ExamineSystemShared _examineSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<DetailExaminableComponent, GetVerbsEvent<ExamineVerb>>(OnGetExamineVerbs);
|
|
}
|
|
|
|
private void OnGetExamineVerbs(EntityUid uid, DetailExaminableComponent component, GetVerbsEvent<ExamineVerb> args)
|
|
{
|
|
if (Identity.Name(args.Target, EntityManager) != MetaData(args.Target).EntityName)
|
|
return;
|
|
|
|
var detailsRange = _examineSystem.IsInDetailsRange(args.User, uid);
|
|
|
|
var verb = new ExamineVerb()
|
|
{
|
|
Act = () =>
|
|
{
|
|
var markup = new FormattedMessage();
|
|
markup.AddMarkupOrThrow(component.Content);
|
|
_examineSystem.SendExamineTooltip(args.User, uid, markup, false, false);
|
|
},
|
|
Text = Loc.GetString("detail-examinable-verb-text"),
|
|
Category = VerbCategory.Examine,
|
|
Disabled = !detailsRange,
|
|
Message = detailsRange ? null : Loc.GetString("detail-examinable-verb-disabled"),
|
|
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/examine.svg.192dpi.png"))
|
|
};
|
|
|
|
args.Verbs.Add(verb);
|
|
}
|
|
}
|
|
}
|