1
0

ResearchClientComponent.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using Robust.Shared.Serialization;
  2. namespace Content.Shared.Research.Components
  3. {
  4. /// <summary>
  5. /// This is an entity that is able to connect to a <see cref="ResearchServerComponent"/>
  6. /// </summary>
  7. [RegisterComponent]
  8. public sealed partial class ResearchClientComponent : Component
  9. {
  10. public bool ConnectedToServer => Server != null;
  11. /// <summary>
  12. /// The server the client is connected to
  13. /// </summary>
  14. [ViewVariables(VVAccess.ReadOnly)]
  15. public EntityUid? Server { get; set; }
  16. }
  17. /// <summary>
  18. /// Raised on the client whenever its server is changed
  19. /// </summary>
  20. /// <param name="Server">Its new server</param>
  21. [ByRefEvent]
  22. public readonly record struct ResearchRegistrationChangedEvent(EntityUid? Server);
  23. /// <summary>
  24. /// Sent to the server when the client deselects a research server.
  25. /// </summary>
  26. [Serializable, NetSerializable]
  27. public sealed class ResearchClientServerDeselectedMessage : BoundUserInterfaceMessage
  28. {
  29. }
  30. /// <summary>
  31. /// Sent to the server when the client chooses a research server.
  32. /// </summary>
  33. [Serializable, NetSerializable]
  34. public sealed class ResearchClientServerSelectedMessage : BoundUserInterfaceMessage
  35. {
  36. public int ServerId;
  37. public ResearchClientServerSelectedMessage(int serverId)
  38. {
  39. ServerId = serverId;
  40. }
  41. }
  42. /// <summary>
  43. /// Request that the server updates the client.
  44. /// </summary>
  45. [Serializable, NetSerializable]
  46. public sealed class ResearchClientSyncMessage : BoundUserInterfaceMessage
  47. {
  48. }
  49. [NetSerializable, Serializable]
  50. public enum ResearchClientUiKey
  51. {
  52. Key,
  53. }
  54. [Serializable, NetSerializable]
  55. public sealed class ResearchClientBoundInterfaceState : BoundUserInterfaceState
  56. {
  57. public int ServerCount;
  58. public string[] ServerNames;
  59. public int[] ServerIds;
  60. public int SelectedServerId;
  61. public ResearchClientBoundInterfaceState(int serverCount, string[] serverNames, int[] serverIds, int selectedServerId = -1)
  62. {
  63. ServerCount = serverCount;
  64. ServerNames = serverNames;
  65. ServerIds = serverIds;
  66. SelectedServerId = selectedServerId;
  67. }
  68. }
  69. }