LogicGateComponent.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Content.Server.DeviceLinking.Systems;
  2. using Content.Shared.DeviceLinking;
  3. using Content.Shared.Tools;
  4. using Robust.Shared.Audio;
  5. using Robust.Shared.Prototypes;
  6. namespace Content.Server.DeviceLinking.Components;
  7. /// <summary>
  8. /// A logic gate that sets its output port by doing an operation on its 2 input ports, A and B.
  9. /// </summary>
  10. [RegisterComponent, Access(typeof(LogicGateSystem))]
  11. public sealed partial class LogicGateComponent : Component
  12. {
  13. /// <summary>
  14. /// The logic gate operation to use.
  15. /// </summary>
  16. [DataField]
  17. public LogicGate Gate = LogicGate.Or;
  18. /// <summary>
  19. /// Tool quality to use for cycling logic gate operations.
  20. /// Cannot be pulsing since linking uses that.
  21. /// </summary>
  22. [DataField, ViewVariables(VVAccess.ReadWrite)]
  23. public ProtoId<ToolQualityPrototype> CycleQuality = "Screwing";
  24. /// <summary>
  25. /// Sound played when cycling logic gate operations.
  26. /// </summary>
  27. [DataField]
  28. public SoundSpecifier CycleSound = new SoundPathSpecifier("/Audio/Machines/lightswitch.ogg");
  29. /// <summary>
  30. /// Name of the first input port.
  31. /// </summary>
  32. [DataField, ViewVariables(VVAccess.ReadWrite)]
  33. public ProtoId<SinkPortPrototype> InputPortA = "InputA";
  34. /// <summary>
  35. /// Name of the second input port.
  36. /// </summary>
  37. [DataField, ViewVariables(VVAccess.ReadWrite)]
  38. public ProtoId<SinkPortPrototype> InputPortB = "InputB";
  39. /// <summary>
  40. /// Name of the output port.
  41. /// </summary>
  42. [DataField, ViewVariables(VVAccess.ReadWrite)]
  43. public ProtoId<SourcePortPrototype> OutputPort = "Output";
  44. // Initial state
  45. [DataField]
  46. public SignalState StateA = SignalState.Low;
  47. [DataField]
  48. public SignalState StateB = SignalState.Low;
  49. [DataField]
  50. public bool LastOutput;
  51. }
  52. /// <summary>
  53. /// Last state of a signal port, used to not spam invoking ports.
  54. /// </summary>
  55. public enum SignalState : byte
  56. {
  57. Momentary, // Instantaneous pulse high, compatibility behavior
  58. Low,
  59. High
  60. }