IdCardConsoleComponent.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using Content.Shared.Access.Systems;
  2. using Content.Shared.Containers.ItemSlots;
  3. using Robust.Shared.GameStates;
  4. using Robust.Shared.Prototypes;
  5. using Robust.Shared.Serialization;
  6. namespace Content.Shared.Access.Components;
  7. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  8. [Access(typeof(SharedIdCardConsoleSystem))]
  9. public sealed partial class IdCardConsoleComponent : Component
  10. {
  11. public const int MaxFullNameLength = 30;
  12. public const int MaxJobTitleLength = 30;
  13. public static string PrivilegedIdCardSlotId = "IdCardConsole-privilegedId";
  14. public static string TargetIdCardSlotId = "IdCardConsole-targetId";
  15. [DataField]
  16. public ItemSlot PrivilegedIdSlot = new();
  17. [DataField]
  18. public ItemSlot TargetIdSlot = new();
  19. [Serializable, NetSerializable]
  20. public sealed class WriteToTargetIdMessage : BoundUserInterfaceMessage
  21. {
  22. public readonly string FullName;
  23. public readonly string JobTitle;
  24. public readonly List<ProtoId<AccessLevelPrototype>> AccessList;
  25. public readonly ProtoId<AccessLevelPrototype> JobPrototype;
  26. public WriteToTargetIdMessage(string fullName, string jobTitle, List<ProtoId<AccessLevelPrototype>> accessList, ProtoId<AccessLevelPrototype> jobPrototype)
  27. {
  28. FullName = fullName;
  29. JobTitle = jobTitle;
  30. AccessList = accessList;
  31. JobPrototype = jobPrototype;
  32. }
  33. }
  34. // Put this on shared so we just send the state once in PVS range rather than every time the UI updates.
  35. [DataField, AutoNetworkedField]
  36. public List<ProtoId<AccessLevelPrototype>> AccessLevels = new()
  37. {
  38. "Armory",
  39. "Atmospherics",
  40. "Bar",
  41. "Brig",
  42. "Detective",
  43. "Captain",
  44. "Cargo",
  45. "Chapel",
  46. "Chemistry",
  47. "ChiefEngineer",
  48. "ChiefMedicalOfficer",
  49. "Command",
  50. "Cryogenics",
  51. "Engineering",
  52. "External",
  53. "HeadOfPersonnel",
  54. "HeadOfSecurity",
  55. "Hydroponics",
  56. "Janitor",
  57. "Kitchen",
  58. "Lawyer",
  59. "Maintenance",
  60. "Medical",
  61. "Quartermaster",
  62. "Research",
  63. "ResearchDirector",
  64. "Salvage",
  65. "Security",
  66. "Service",
  67. "Theatre",
  68. };
  69. [Serializable, NetSerializable]
  70. public sealed class IdCardConsoleBoundUserInterfaceState : BoundUserInterfaceState
  71. {
  72. public readonly string PrivilegedIdName;
  73. public readonly bool IsPrivilegedIdPresent;
  74. public readonly bool IsPrivilegedIdAuthorized;
  75. public readonly bool IsTargetIdPresent;
  76. public readonly string TargetIdName;
  77. public readonly string? TargetIdFullName;
  78. public readonly string? TargetIdJobTitle;
  79. public readonly List<ProtoId<AccessLevelPrototype>>? TargetIdAccessList;
  80. public readonly List<ProtoId<AccessLevelPrototype>>? AllowedModifyAccessList;
  81. public readonly ProtoId<AccessLevelPrototype> TargetIdJobPrototype;
  82. public IdCardConsoleBoundUserInterfaceState(bool isPrivilegedIdPresent,
  83. bool isPrivilegedIdAuthorized,
  84. bool isTargetIdPresent,
  85. string? targetIdFullName,
  86. string? targetIdJobTitle,
  87. List<ProtoId<AccessLevelPrototype>>? targetIdAccessList,
  88. List<ProtoId<AccessLevelPrototype>>? allowedModifyAccessList,
  89. ProtoId<AccessLevelPrototype> targetIdJobPrototype,
  90. string privilegedIdName,
  91. string targetIdName)
  92. {
  93. IsPrivilegedIdPresent = isPrivilegedIdPresent;
  94. IsPrivilegedIdAuthorized = isPrivilegedIdAuthorized;
  95. IsTargetIdPresent = isTargetIdPresent;
  96. TargetIdFullName = targetIdFullName;
  97. TargetIdJobTitle = targetIdJobTitle;
  98. TargetIdAccessList = targetIdAccessList;
  99. AllowedModifyAccessList = allowedModifyAccessList;
  100. TargetIdJobPrototype = targetIdJobPrototype;
  101. PrivilegedIdName = privilegedIdName;
  102. TargetIdName = targetIdName;
  103. }
  104. }
  105. [Serializable, NetSerializable]
  106. public enum IdCardConsoleUiKey : byte
  107. {
  108. Key,
  109. }
  110. }