GhostRoleComponent.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using Content.Server.Ghost.Roles.Raffles;
  2. using Content.Server.Mind.Commands;
  3. using Content.Shared.Roles;
  4. using Robust.Shared.Prototypes;
  5. namespace Content.Server.Ghost.Roles.Components;
  6. [RegisterComponent]
  7. [Access(typeof(GhostRoleSystem))]
  8. public sealed partial class GhostRoleComponent : Component
  9. {
  10. [DataField("name")] private string _roleName = "Unknown";
  11. [DataField("description")] private string _roleDescription = "Unknown";
  12. [DataField("rules")] private string _roleRules = "ghost-role-component-default-rules";
  13. // Actually make use of / enforce this requirement?
  14. // Why is this even here.
  15. // Move to ghost role prototype & respect CCvars.GameRoleTimerOverride
  16. [DataField("requirements")]
  17. public HashSet<JobRequirement>? Requirements;
  18. /// <summary>
  19. /// Whether the <see cref="MakeSentientCommand"/> should run on the mob.
  20. /// </summary>
  21. [ViewVariables(VVAccess.ReadWrite)] [DataField("makeSentient")]
  22. public bool MakeSentient = true;
  23. /// <summary>
  24. /// The probability that this ghost role will be available after init.
  25. /// Used mostly for takeover roles that want some probability of being takeover, but not 100%.
  26. /// </summary>
  27. [DataField("prob")]
  28. public float Probability = 1f;
  29. // We do this so updating RoleName and RoleDescription in VV updates the open EUIs.
  30. [ViewVariables(VVAccess.ReadWrite)]
  31. [Access(typeof(GhostRoleSystem), Other = AccessPermissions.ReadWriteExecute)] // FIXME Friends
  32. public string RoleName
  33. {
  34. get => Loc.GetString(_roleName);
  35. set
  36. {
  37. _roleName = value;
  38. IoCManager.Resolve<IEntityManager>().System<GhostRoleSystem>().UpdateAllEui();
  39. }
  40. }
  41. [ViewVariables(VVAccess.ReadWrite)]
  42. [Access(typeof(GhostRoleSystem), Other = AccessPermissions.ReadWriteExecute)] // FIXME Friends
  43. public string RoleDescription
  44. {
  45. get => Loc.GetString(_roleDescription);
  46. set
  47. {
  48. _roleDescription = value;
  49. IoCManager.Resolve<IEntityManager>().System<GhostRoleSystem>().UpdateAllEui();
  50. }
  51. }
  52. [ViewVariables(VVAccess.ReadWrite)]
  53. [Access(typeof(GhostRoleSystem), Other = AccessPermissions.ReadWriteExecute)] // FIXME Friends
  54. public string RoleRules
  55. {
  56. get => Loc.GetString(_roleRules);
  57. set
  58. {
  59. _roleRules = value;
  60. IoCManager.Resolve<IEntityManager>().System<GhostRoleSystem>().UpdateAllEui();
  61. }
  62. }
  63. /// <summary>
  64. /// The mind roles that will be added to the mob's mind entity
  65. /// </summary>
  66. [DataField, Access(typeof(GhostRoleSystem), Other = AccessPermissions.ReadWriteExecute)] // Don't make eye contact
  67. public List<EntProtoId> MindRoles = new() { "MindRoleGhostRoleNeutral" };
  68. [DataField]
  69. public bool AllowSpeech { get; set; } = true;
  70. [DataField]
  71. public bool AllowMovement { get; set; }
  72. [ViewVariables(VVAccess.ReadOnly)]
  73. public bool Taken { get; set; }
  74. [ViewVariables]
  75. public uint Identifier { get; set; }
  76. /// <summary>
  77. /// Reregisters the ghost role when the current player ghosts.
  78. /// </summary>
  79. [ViewVariables(VVAccess.ReadWrite)]
  80. [DataField("reregister")]
  81. public bool ReregisterOnGhost { get; set; } = true;
  82. /// <summary>
  83. /// If set, ghost role is raffled, otherwise it is first-come-first-serve.
  84. /// </summary>
  85. [DataField("raffle")]
  86. [Access(typeof(GhostRoleSystem), Other = AccessPermissions.ReadWriteExecute)] // FIXME Friends
  87. public GhostRoleRaffleConfig? RaffleConfig { get; set; }
  88. /// <summary>
  89. /// Job the entity will receive after adding the mind.
  90. /// </summary>
  91. [DataField("job")]
  92. [Access(typeof(GhostRoleSystem), Other = AccessPermissions.ReadWriteExecute)] // also FIXME Friends
  93. public ProtoId<JobPrototype>? JobProto = null;
  94. }