using Content.Server.DeviceLinking.Systems;
using Content.Shared.DeviceLinking;
using Content.Shared.Tools;
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.DeviceLinking.Components;
///
/// A logic gate that sets its output port by doing an operation on its 2 input ports, A and B.
///
[RegisterComponent]
[Access(typeof(LogicGateSystem))]
public sealed class LogicGateComponent : Component
{
///
/// The logic gate operation to use.
///
[DataField("gate")]
public LogicGate Gate = LogicGate.Or;
///
/// Tool quality to use for cycling logic gate operations.
/// Cannot be pulsing since linking uses that.
///
[DataField("cycleQuality", customTypeSerializer: typeof(PrototypeIdSerializer))]
public string CycleQuality = "Screwing";
///
/// Sound played when cycling logic gate operations.
///
[DataField("cycleSound")]
public SoundSpecifier CycleSound = new SoundPathSpecifier("/Audio/Machines/lightswitch.ogg");
///
/// Name of the first input port.
///
[DataField("inputPortA", customTypeSerializer: typeof(PrototypeIdSerializer))]
public string InputPortA = "InputA";
///
/// Name of the second input port.
///
[DataField("inputPortB", customTypeSerializer: typeof(PrototypeIdSerializer))]
public string InputPortB = "InputB";
///
/// Name of the output port.
///
[DataField("outputPort", customTypeSerializer: typeof(PrototypeIdSerializer))]
public string OutputPort = "Output";
// Initial state
[ViewVariables]
public SignalState StateA = SignalState.Low;
[ViewVariables]
public SignalState StateB = SignalState.Low;
[ViewVariables]
public bool LastOutput;
}
///
/// Last state of a signal port, used to not spam invoking ports.
///
public enum SignalState : byte
{
Momentary, // Instantaneous pulse high, compatibility behavior
Low,
High
}