1
0

DeviceNetworkComponent.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using Content.Server.DeviceNetwork.Systems;
  2. using Content.Shared.DeviceNetwork;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  4. namespace Content.Server.DeviceNetwork.Components
  5. {
  6. [RegisterComponent]
  7. [Access(typeof(DeviceNetworkSystem), typeof(DeviceNet))]
  8. public sealed partial class DeviceNetworkComponent : Component
  9. {
  10. public enum DeviceNetIdDefaults
  11. {
  12. Private,
  13. Wired,
  14. Wireless,
  15. Apc,
  16. AtmosDevices,
  17. Reserved = 100,
  18. // Ids outside this enum may exist
  19. // This exists to let yml use nice names instead of numbers
  20. }
  21. [DataField("deviceNetId")]
  22. public DeviceNetIdDefaults NetIdEnum { get; set; }
  23. public int DeviceNetId => (int) NetIdEnum;
  24. /// <summary>
  25. /// The frequency that this device is listening on.
  26. /// </summary>
  27. [DataField("receiveFrequency")]
  28. public uint? ReceiveFrequency;
  29. /// <summary>
  30. /// frequency prototype. Used to select a default frequency to listen to on. Used when the map is
  31. /// initialized.
  32. /// </summary>
  33. [DataField("receiveFrequencyId", customTypeSerializer: typeof(PrototypeIdSerializer<DeviceFrequencyPrototype>))]
  34. public string? ReceiveFrequencyId;
  35. /// <summary>
  36. /// The frequency that this device going to try transmit on.
  37. /// </summary>
  38. [ViewVariables(VVAccess.ReadWrite)]
  39. [DataField("transmitFrequency")]
  40. public uint? TransmitFrequency;
  41. /// <summary>
  42. /// frequency prototype. Used to select a default frequency to transmit on. Used when the map is
  43. /// initialized.
  44. /// </summary>
  45. [DataField("transmitFrequencyId", customTypeSerializer: typeof(PrototypeIdSerializer<DeviceFrequencyPrototype>))]
  46. public string? TransmitFrequencyId;
  47. /// <summary>
  48. /// The address of the device, either on the network it is currently connected to or whatever address it
  49. /// most recently used.
  50. /// </summary>
  51. [DataField("address")]
  52. public string Address = string.Empty;
  53. /// <summary>
  54. /// If true, the address was customized and should be preserved across networks. If false, a randomly
  55. /// generated address will be created whenever this device connects to a network.
  56. /// </summary>
  57. [DataField("customAddress")]
  58. public bool CustomAddress = false;
  59. /// <summary>
  60. /// Prefix to prepend to any automatically generated addresses. Helps players to identify devices. This gets
  61. /// localized.
  62. /// </summary>
  63. [ViewVariables(VVAccess.ReadWrite)]
  64. [DataField("prefix")]
  65. public string? Prefix;
  66. /// <summary>
  67. /// Whether the device should listen for all device messages, regardless of the intended recipient.
  68. /// </summary>
  69. [DataField("receiveAll")]
  70. public bool ReceiveAll;
  71. /// <summary>
  72. /// If the device should show its address upon an examine. Useful for devices
  73. /// that do not have a visible UI.
  74. /// </summary>
  75. [DataField("examinableAddress")]
  76. public bool ExaminableAddress;
  77. /// <summary>
  78. /// Whether the device should attempt to join the network on map init.
  79. /// </summary>
  80. [ViewVariables(VVAccess.ReadWrite)]
  81. [DataField("autoConnect")]
  82. public bool AutoConnect = true;
  83. /// <summary>
  84. /// Whether to send the broadcast recipients list to the sender so it can be filtered.
  85. /// <see cref="DeviceListSystem"/>
  86. /// </summary>
  87. [ViewVariables(VVAccess.ReadWrite)]
  88. [DataField("sendBroadcastAttemptEvent")]
  89. public bool SendBroadcastAttemptEvent = false;
  90. /// <summary>
  91. /// Whether this device's address can be saved to device-lists
  92. /// </summary>
  93. [ViewVariables(VVAccess.ReadWrite)]
  94. [DataField("savableAddress")]
  95. public bool SavableAddress = true;
  96. /// <summary>
  97. /// A list of device-lists that this device is on.
  98. /// </summary>
  99. [DataField]
  100. [Access(typeof(DeviceListSystem))]
  101. public HashSet<EntityUid> DeviceLists = new();
  102. /// <summary>
  103. /// A list of configurators that this device is on.
  104. /// </summary>
  105. [DataField]
  106. [Access(typeof(NetworkConfiguratorSystem))]
  107. public HashSet<EntityUid> Configurators = new();
  108. }
  109. }