Files
tbd-station-14/Content.Shared/IdentityManagement/SharedIdentitySystem.cs
Arendian 60b9d89e4d Criminal record hud icons (#25192)
* Security hud shows icon based on criminal record status

* Criminal status now linked to name instead of identity

* parole loc

* Test fix

* review changes

* Check station records instead of storing names on criminal record consoles.

* cleanup

* more cleanup

* review changes

* change outdated comments

* rename

* review changes

* remove event subscription

* replaced event with trycomp

* default value
2024-03-11 14:12:52 +11:00

48 lines
1.7 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.TotalCoverage |= component.Coverage;
if(args.TotalCoverage == IdentityBlockerCoverage.FULL)
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;
}
}
/// <summary>
/// Gets called whenever an entity changes their identity.
/// </summary>
[ByRefEvent]
public record struct IdentityChangedEvent(EntityUid CharacterEntity, EntityUid IdentityEntity);