* Move MaskComponent to shared and add toggle events * Datafield and network IsToggled * Add missing dirty
39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using Content.Shared.Clothing;
|
|
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));
|
|
SubscribeLocalEvent<IdentityBlockerComponent, ItemMaskToggledEvent>(OnMaskToggled);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
private void OnMaskToggled(Entity<IdentityBlockerComponent> ent, ref ItemMaskToggledEvent args)
|
|
{
|
|
ent.Comp.Enabled = !args.IsToggled;
|
|
}
|
|
}
|