32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using Content.Shared.IdentityManagement.Components;
|
|
using Content.Shared.Inventory;
|
|
using Robust.Shared.Containers;
|
|
|
|
namespace Content.Shared.IdentityManagement;
|
|
|
|
public abstract class SharedIdentitySystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
|
private static string SlotName = "identity";
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<IdentityComponent, ComponentInit>(OnComponentInit);
|
|
SubscribeLocalEvent<IdentityBlockerComponent, SeeIdentityAttemptEvent>(OnSeeIdentity);
|
|
SubscribeLocalEvent<IdentityBlockerComponent, InventoryRelayedEvent<SeeIdentityAttemptEvent>>((e, c, ev) => OnSeeIdentity(e, c, ev.Args));
|
|
}
|
|
|
|
private void OnSeeIdentity(EntityUid uid, IdentityBlockerComponent component, SeeIdentityAttemptEvent args)
|
|
{
|
|
if (component.Enabled)
|
|
args.Cancel();
|
|
}
|
|
|
|
protected virtual void OnComponentInit(EntityUid uid, IdentityComponent component, ComponentInit args)
|
|
{
|
|
component.IdentityEntitySlot = _container.EnsureContainer<ContainerSlot>(uid, SlotName);
|
|
}
|
|
}
|