SharedCrayonComponent.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using Robust.Shared.GameStates;
  2. using Robust.Shared.Serialization;
  3. namespace Content.Shared.Crayon
  4. {
  5. /// <summary>
  6. /// Component holding the state of a crayon-like component
  7. /// </summary>
  8. [NetworkedComponent, ComponentProtoName("Crayon"), Access(typeof(SharedCrayonSystem))]
  9. public abstract partial class SharedCrayonComponent : Component
  10. {
  11. /// <summary>
  12. /// The ID of currently selected decal prototype that will be placed when the crayon is used
  13. /// </summary>
  14. public string SelectedState { get; set; } = string.Empty;
  15. /// <summary>
  16. /// Color with which the crayon will draw
  17. /// </summary>
  18. [DataField("color")]
  19. public Color Color;
  20. [Serializable, NetSerializable]
  21. public enum CrayonUiKey : byte
  22. {
  23. Key,
  24. }
  25. }
  26. /// <summary>
  27. /// Used by the client to notify the server about the selected decal ID
  28. /// </summary>
  29. [Serializable, NetSerializable]
  30. public sealed class CrayonSelectMessage : BoundUserInterfaceMessage
  31. {
  32. public readonly string State;
  33. public CrayonSelectMessage(string selected)
  34. {
  35. State = selected;
  36. }
  37. }
  38. /// <summary>
  39. /// Sets the color of the crayon, used by Rainbow Crayon
  40. /// </summary>
  41. [Serializable, NetSerializable]
  42. public sealed class CrayonColorMessage : BoundUserInterfaceMessage
  43. {
  44. public readonly Color Color;
  45. public CrayonColorMessage(Color color)
  46. {
  47. Color = color;
  48. }
  49. }
  50. /// <summary>
  51. /// Server to CLIENT. Notifies the BUI that a decal with given ID has been drawn.
  52. /// Allows the client UI to advance forward in the client-only ephemeral queue,
  53. /// preventing the crayon from becoming a magic text storage device.
  54. /// </summary>
  55. [Serializable, NetSerializable]
  56. public sealed class CrayonUsedMessage : BoundUserInterfaceMessage
  57. {
  58. public readonly string DrawnDecal;
  59. public CrayonUsedMessage(string drawn)
  60. {
  61. DrawnDecal = drawn;
  62. }
  63. }
  64. /// <summary>
  65. /// Component state, describes how many charges are left in the crayon in the near-hand UI
  66. /// </summary>
  67. [Serializable, NetSerializable]
  68. public sealed class CrayonComponentState : ComponentState
  69. {
  70. public readonly Color Color;
  71. public readonly string State;
  72. public readonly int Charges;
  73. public readonly int Capacity;
  74. public CrayonComponentState(Color color, string state, int charges, int capacity)
  75. {
  76. Color = color;
  77. State = state;
  78. Charges = charges;
  79. Capacity = capacity;
  80. }
  81. }
  82. /// <summary>
  83. /// The state of the crayon UI as sent by the server
  84. /// </summary>
  85. [Serializable, NetSerializable]
  86. public sealed class CrayonBoundUserInterfaceState : BoundUserInterfaceState
  87. {
  88. public string Selected;
  89. /// <summary>
  90. /// Whether or not the color can be selected
  91. /// </summary>
  92. public bool SelectableColor;
  93. public Color Color;
  94. public CrayonBoundUserInterfaceState(string selected, bool selectableColor, Color color)
  95. {
  96. Selected = selected;
  97. SelectableColor = selectableColor;
  98. Color = color;
  99. }
  100. }
  101. }