CatStation/Content.Server/Corvax/HiddenDescription/HiddenDescriptionSystem.cs
Ed cec88aef03
IC contraband and staff knowledge of the items (#1767)
Co-authored-by: Kit0vras <123590995+Kit0vras@users.noreply.github.com>
Co-authored-by: Morb <14136326+Morb0@users.noreply.github.com>
2024-03-21 00:57:25 +03:00

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);
}
}
}