MindContainerComponent.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System.Diagnostics.CodeAnalysis;
  2. using Robust.Shared.GameStates;
  3. namespace Content.Shared.Mind.Components;
  4. /// <summary>
  5. /// This component indicates that this entity may have mind, which is simply an entity with a <see cref="MindComponent"/>.
  6. /// The mind entity is not actually stored in a "container", but is simply stored in nullspace.
  7. /// </summary>
  8. [RegisterComponent, Access(typeof(SharedMindSystem)), NetworkedComponent, AutoGenerateComponentState]
  9. public sealed partial class MindContainerComponent : Component
  10. {
  11. /// <summary>
  12. /// The mind controlling this mob. Can be null.
  13. /// </summary>
  14. [DataField, AutoNetworkedField]
  15. public EntityUid? Mind { get; set; }
  16. /// <summary>
  17. /// True if we have a mind, false otherwise.
  18. /// </summary>
  19. [MemberNotNullWhen(true, nameof(Mind))]
  20. public bool HasMind => Mind != null;
  21. /// <summary>
  22. /// Whether examining should show information about the mind or not.
  23. /// </summary>
  24. [ViewVariables(VVAccess.ReadWrite)]
  25. [DataField("showExamineInfo"), AutoNetworkedField]
  26. public bool ShowExamineInfo { get; set; }
  27. /// <summary>
  28. /// Whether the mind will be put on a ghost after this component is shutdown.
  29. /// </summary>
  30. [ViewVariables(VVAccess.ReadWrite)]
  31. [DataField("ghostOnShutdown")]
  32. public bool GhostOnShutdown { get; set; } = true;
  33. }
  34. public abstract class MindEvent : EntityEventArgs
  35. {
  36. public readonly Entity<MindComponent> Mind;
  37. public readonly Entity<MindContainerComponent> Container;
  38. public MindEvent(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
  39. {
  40. Mind = mind;
  41. Container = container;
  42. }
  43. }
  44. /// <summary>
  45. /// Event raised directed at a mind-container when a mind gets removed.
  46. /// </summary>
  47. public sealed class MindRemovedMessage : MindEvent
  48. {
  49. public MindRemovedMessage(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
  50. : base(mind, container)
  51. {
  52. }
  53. }
  54. /// <summary>
  55. /// Event raised directed at a mind when it gets removed from a mind-container.
  56. /// </summary>
  57. public sealed class MindGotRemovedEvent : MindEvent
  58. {
  59. public MindGotRemovedEvent(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
  60. : base(mind, container)
  61. {
  62. }
  63. }
  64. /// <summary>
  65. /// Event raised directed at a mind-container when a mind gets added.
  66. /// </summary>
  67. public sealed class MindAddedMessage : MindEvent
  68. {
  69. public MindAddedMessage(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
  70. : base(mind, container)
  71. {
  72. }
  73. }
  74. /// <summary>
  75. /// Event raised directed at a mind when it gets added to a mind-container.
  76. /// </summary>
  77. public sealed class MindGotAddedEvent : MindEvent
  78. {
  79. public MindGotAddedEvent(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
  80. : base(mind, container)
  81. {
  82. }
  83. }