SharedAccessOverriderSystem.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Content.Shared.Access.Components;
  2. using Content.Shared.Containers.ItemSlots;
  3. using Content.Shared.DoAfter;
  4. using JetBrains.Annotations;
  5. using Robust.Shared.Serialization;
  6. namespace Content.Shared.Access.Systems
  7. {
  8. [UsedImplicitly]
  9. public abstract partial class SharedAccessOverriderSystem : EntitySystem
  10. {
  11. [Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
  12. [Dependency] private readonly ILogManager _log = default!;
  13. public const string Sawmill = "accessoverrider";
  14. protected ISawmill _sawmill = default!;
  15. public override void Initialize()
  16. {
  17. base.Initialize();
  18. _sawmill = _log.GetSawmill(Sawmill);
  19. SubscribeLocalEvent<AccessOverriderComponent, ComponentInit>(OnComponentInit);
  20. SubscribeLocalEvent<AccessOverriderComponent, ComponentRemove>(OnComponentRemove);
  21. }
  22. private void OnComponentInit(EntityUid uid, AccessOverriderComponent component, ComponentInit args)
  23. {
  24. _itemSlotsSystem.AddItemSlot(uid, AccessOverriderComponent.PrivilegedIdCardSlotId, component.PrivilegedIdSlot);
  25. }
  26. private void OnComponentRemove(EntityUid uid, AccessOverriderComponent component, ComponentRemove args)
  27. {
  28. _itemSlotsSystem.RemoveItemSlot(uid, component.PrivilegedIdSlot);
  29. }
  30. [Serializable, NetSerializable]
  31. public sealed partial class AccessOverriderDoAfterEvent : DoAfterEvent
  32. {
  33. public AccessOverriderDoAfterEvent()
  34. {
  35. }
  36. public override DoAfterEvent Clone() => this;
  37. }
  38. }
  39. }
  40. [ByRefEvent]
  41. public record struct OnAccessOverriderAccessUpdatedEvent(EntityUid UserUid, bool Handled = false);