PowerSwitchableComponent.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using Robust.Shared.Audio;
  2. using Robust.Shared.GameStates;
  3. using Robust.Shared.Serialization;
  4. namespace Content.Shared.Power.Generator;
  5. /// <summary>
  6. /// Enables a device to switch between HV, MV and LV connectors.
  7. /// For generators this means changing output wires.
  8. /// </summary>
  9. /// <remarks>
  10. /// Must have <c>CableDeviceNode</c>s for each output in <see cref="Outputs"/>.
  11. /// If its a generator <c>PowerSupplierComponent</c> is also required.
  12. /// </remarks>
  13. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  14. [Access(typeof(SharedPowerSwitchableSystem))]
  15. public sealed partial class PowerSwitchableComponent : Component
  16. {
  17. /// <summary>
  18. /// Index into <see cref="Cables"/> that the device is currently using.
  19. /// </summary>
  20. [DataField, AutoNetworkedField]
  21. public int ActiveIndex;
  22. /// <summary>
  23. /// Sound that plays when the cable is switched.
  24. /// </summary>
  25. [DataField]
  26. public SoundSpecifier? SwitchSound = new SoundPathSpecifier("/Audio/Machines/button.ogg");
  27. /// <summary>
  28. /// Locale id for text shown when examined.
  29. /// It is given "voltage" as a colored voltage string.
  30. /// </summary>
  31. [DataField(required: true)]
  32. public string ExamineText = string.Empty;
  33. /// <summary>
  34. /// Locale id for the popup shown when switching voltages.
  35. /// It is given "voltage" as a colored voltage string.
  36. /// </summary>
  37. [DataField(required: true)]
  38. public string SwitchText = string.Empty;
  39. /// <summary>
  40. /// Cable voltages and their nodes which can be cycled between.
  41. /// Each node name must match a cable node in its <c>NodeContainer</c>.
  42. /// </summary>
  43. [DataField(required: true)]
  44. public List<PowerSwitchableCable> Cables = new();
  45. }
  46. /// <summary>
  47. /// Cable voltage and node name for cycling.
  48. /// </summary>
  49. [DataDefinition]
  50. public sealed partial class PowerSwitchableCable
  51. {
  52. /// <summary>
  53. /// Voltage that the cable uses.
  54. /// </summary>
  55. [DataField(required: true)]
  56. public SwitchableVoltage Voltage;
  57. /// <summary>
  58. /// Name of the node for the cable.
  59. /// Must be a <c>CableDeviceNode</c>
  60. /// </summary>
  61. [DataField(required: true)]
  62. public string Node = string.Empty;
  63. }
  64. /// <summary>
  65. /// Cable voltage to cycle between.
  66. /// </summary>
  67. [Serializable, NetSerializable]
  68. public enum SwitchableVoltage : byte
  69. {
  70. HV,
  71. MV,
  72. LV
  73. }