SharedIdCardConsoleSystem.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Content.Shared.Access.Components;
  2. using Content.Shared.Containers.ItemSlots;
  3. using JetBrains.Annotations;
  4. using Robust.Shared.GameStates;
  5. using Robust.Shared.Serialization;
  6. using Robust.Shared.Prototypes;
  7. namespace Content.Shared.Access.Systems
  8. {
  9. [UsedImplicitly]
  10. public abstract class SharedIdCardConsoleSystem : EntitySystem
  11. {
  12. [Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
  13. [Dependency] private readonly ILogManager _log = default!;
  14. public const string Sawmill = "idconsole";
  15. protected ISawmill _sawmill = default!;
  16. public override void Initialize()
  17. {
  18. base.Initialize();
  19. _sawmill = _log.GetSawmill(Sawmill);
  20. SubscribeLocalEvent<IdCardConsoleComponent, ComponentInit>(OnComponentInit);
  21. SubscribeLocalEvent<IdCardConsoleComponent, ComponentRemove>(OnComponentRemove);
  22. }
  23. private void OnComponentInit(EntityUid uid, IdCardConsoleComponent component, ComponentInit args)
  24. {
  25. _itemSlotsSystem.AddItemSlot(uid, IdCardConsoleComponent.PrivilegedIdCardSlotId, component.PrivilegedIdSlot);
  26. _itemSlotsSystem.AddItemSlot(uid, IdCardConsoleComponent.TargetIdCardSlotId, component.TargetIdSlot);
  27. }
  28. private void OnComponentRemove(EntityUid uid, IdCardConsoleComponent component, ComponentRemove args)
  29. {
  30. _itemSlotsSystem.RemoveItemSlot(uid, component.PrivilegedIdSlot);
  31. _itemSlotsSystem.RemoveItemSlot(uid, component.TargetIdSlot);
  32. }
  33. [Serializable, NetSerializable]
  34. private sealed class IdCardConsoleComponentState : ComponentState
  35. {
  36. public List<string> AccessLevels;
  37. public IdCardConsoleComponentState(List<string> accessLevels)
  38. {
  39. AccessLevels = accessLevels;
  40. }
  41. }
  42. }
  43. }