mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-13 04:11:13 +03:00
Co-authored-by: Kit0vras <123590995+Kit0vras@users.noreply.github.com> Co-authored-by: Morb <14136326+Morb0@users.noreply.github.com>
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using Content.Server.Mind;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.Roles.Jobs;
|
|
|
|
namespace Content.Server.Corvax.HiddenDescription;
|
|
|
|
public sealed partial class HiddenDescriptionSystem : EntitySystem
|
|
{
|
|
|
|
[Dependency] private readonly MindSystem _mind = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<HiddenDescriptionComponent, ExaminedEvent>(OnExamine);
|
|
}
|
|
|
|
private void OnExamine(Entity<HiddenDescriptionComponent> hiddenDesc, ref ExaminedEvent args)
|
|
{
|
|
_mind.TryGetMind(args.Examiner, out var mindId, out var mindComponent);
|
|
TryComp<JobComponent>(mindId, out var job);
|
|
|
|
foreach (var item in hiddenDesc.Comp.Entries)
|
|
{
|
|
var isJobAllow = job?.Prototype != null && item.JobRequired.Contains(job.Prototype.Value);
|
|
var isMindWhitelistPassed = item.WhitelistMind.IsValid(mindId);
|
|
var isBodyWhitelistPassed = item.WhitelistMind.IsValid(args.Examiner);
|
|
var passed = item.NeedAllCheck
|
|
? isMindWhitelistPassed && isBodyWhitelistPassed && isJobAllow
|
|
: isMindWhitelistPassed || isBodyWhitelistPassed || isJobAllow;
|
|
|
|
if (passed)
|
|
args.PushMarkup(Loc.GetString(item.Label), hiddenDesc.Comp.PushPriority);
|
|
}
|
|
}
|
|
}
|