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

@@ -1,35 +1,34 @@
using Content.Server.DeviceLinking.Systems;
using Content.Shared.DeviceLinking;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Prototypes;
namespace Content.Server.DeviceLinking.Components;
/// <summary>
/// An edge detector that pulses high or low output ports when the input port gets a rising or falling edge respectively.
/// </summary>
[RegisterComponent]
[Access(typeof(EdgeDetectorSystem))]
[RegisterComponent, Access(typeof(EdgeDetectorSystem))]
public sealed partial class EdgeDetectorComponent : Component
{
/// <summary>
/// Name of the input port.
/// </summary>
[DataField("inputPort", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
public string InputPort = "Input";
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<SinkPortPrototype> InputPort = "Input";
/// <summary>
/// Name of the rising edge output port.
/// </summary>
[DataField("outputHighPort", customTypeSerializer: typeof(PrototypeIdSerializer<SourcePortPrototype>))]
public string OutputHighPort = "OutputHigh";
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<SourcePortPrototype> OutputHighPort = "OutputHigh";
/// <summary>
/// Name of the falling edge output port.
/// </summary>
[DataField("outputLowPort", customTypeSerializer: typeof(PrototypeIdSerializer<SourcePortPrototype>))]
public string OutputLowPort = "OutputLow";
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId<SourcePortPrototype> OutputLowPort = "OutputLow";
// Initial state
[ViewVariables]
[DataField]
public SignalState State = SignalState.Low;
}