1
0

AdminData.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. 
  2. namespace Content.Shared.Administration
  3. {
  4. /// <summary>
  5. /// Represents data for a single server admin.
  6. /// </summary>
  7. public sealed class AdminData
  8. {
  9. // Can be false if they're de-adminned with the ability to re-admin.
  10. /// <summary>
  11. /// Whether the admin is currently active. This can be false if they have de-adminned mid-round.
  12. /// </summary>
  13. public bool Active;
  14. /// <summary>
  15. /// Whether the admin is in stealth mode and won't appear in adminwho to admins without the Stealth flag.
  16. /// </summary>
  17. public bool Stealth;
  18. /// <summary>
  19. /// The admin's title.
  20. /// </summary>
  21. public string? Title;
  22. /// <summary>
  23. /// The admin's permission flags.
  24. /// </summary>
  25. public AdminFlags Flags;
  26. /// <summary>
  27. /// Checks whether this admin has an admin flag.
  28. /// </summary>
  29. /// <param name="flag">The flags to check. Multiple flags can be specified, they must all be held.</param>
  30. /// <param name="includeDeAdmin">If true then also count flags even if the admin has de-adminned.</param>
  31. /// <returns>False if this admin is not <see cref="Active"/> or does not have all the flags specified.</returns>
  32. public bool HasFlag(AdminFlags flag, bool includeDeAdmin = false)
  33. {
  34. return (includeDeAdmin || Active) && (Flags & flag) == flag;
  35. }
  36. /// <summary>
  37. /// Check if this admin can spawn stuff in with the entity/tile spawn panel.
  38. /// </summary>
  39. public bool CanAdminPlace()
  40. {
  41. return HasFlag(AdminFlags.Spawn);
  42. }
  43. /// <summary>
  44. /// Check if this admin can execute server-side C# scripts.
  45. /// </summary>
  46. public bool CanScript()
  47. {
  48. return HasFlag(AdminFlags.Host);
  49. }
  50. /// <summary>
  51. /// Check if this admin can open the admin menu.
  52. /// </summary>
  53. public bool CanAdminMenu()
  54. {
  55. return HasFlag(AdminFlags.Admin);
  56. }
  57. /// <summary>
  58. /// Check if this admin can be hidden and see other hidden admins.
  59. /// </summary>
  60. public bool CanStealth()
  61. {
  62. return HasFlag(AdminFlags.Stealth);
  63. }
  64. public bool CanAdminReloadPrototypes()
  65. {
  66. return HasFlag(AdminFlags.Host);
  67. }
  68. }
  69. }