add power sensor (#20400)

* clean up logic gate / edge detector components

* logic gate usedelay support

* new codersprite

* PowerSensor component and system

* add power sensor

* port locale

* fix

* minecraft

* fixy

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-12-16 18:32:42 +00:00
committed by GitHub
parent c936f5adc3
commit d8ee36d7b0
13 changed files with 355 additions and 31 deletions

View File

@@ -2,62 +2,61 @@ 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;
using Robust.Shared.Prototypes;
namespace Content.Server.DeviceLinking.Components;
/// <summary>
/// A logic gate that sets its output port by doing an operation on its 2 input ports, A and B.
/// </summary>
[RegisterComponent]
[Access(typeof(LogicGateSystem))]
[RegisterComponent, Access(typeof(LogicGateSystem))]
public sealed partial class LogicGateComponent : Component
{
/// <summary>
/// The logic gate operation to use.
/// </summary>
[DataField("gate")]
[DataField]
public LogicGate Gate = LogicGate.Or;
/// <summary>
/// Tool quality to use for cycling logic gate operations.
/// Cannot be pulsing since linking uses that.
/// </summary>
[DataField("cycleQuality", customTypeSerializer: typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
public string CycleQuality = "Screwing";
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<ToolQualityPrototype> CycleQuality = "Screwing";
/// <summary>
/// Sound played when cycling logic gate operations.
/// </summary>
[DataField("cycleSound")]
[DataField]
public SoundSpecifier CycleSound = new SoundPathSpecifier("/Audio/Machines/lightswitch.ogg");
/// <summary>
/// Name of the first input port.
/// </summary>
[DataField("inputPortA", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
public string InputPortA = "InputA";
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<SinkPortPrototype> InputPortA = "InputA";
/// <summary>
/// Name of the second input port.
/// </summary>
[DataField("inputPortB", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
public string InputPortB = "InputB";
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<SinkPortPrototype> InputPortB = "InputB";
/// <summary>
/// Name of the output port.
/// </summary>
[DataField("outputPort", customTypeSerializer: typeof(PrototypeIdSerializer<SourcePortPrototype>))]
public string OutputPort = "Output";
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<SourcePortPrototype> OutputPort = "Output";
// Initial state
[ViewVariables]
[DataField]
public SignalState StateA = SignalState.Low;
[ViewVariables]
[DataField]
public SignalState StateB = SignalState.Low;
[ViewVariables]
[DataField]
public bool LastOutput;
}