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:
@@ -1,35 +1,34 @@
|
|||||||
using Content.Server.DeviceLinking.Systems;
|
using Content.Server.DeviceLinking.Systems;
|
||||||
using Content.Shared.DeviceLinking;
|
using Content.Shared.DeviceLinking;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Server.DeviceLinking.Components;
|
namespace Content.Server.DeviceLinking.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An edge detector that pulses high or low output ports when the input port gets a rising or falling edge respectively.
|
/// An edge detector that pulses high or low output ports when the input port gets a rising or falling edge respectively.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent, Access(typeof(EdgeDetectorSystem))]
|
||||||
[Access(typeof(EdgeDetectorSystem))]
|
|
||||||
public sealed partial class EdgeDetectorComponent : Component
|
public sealed partial class EdgeDetectorComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the input port.
|
/// Name of the input port.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("inputPort", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string InputPort = "Input";
|
public ProtoId<SinkPortPrototype> InputPort = "Input";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the rising edge output port.
|
/// Name of the rising edge output port.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("outputHighPort", customTypeSerializer: typeof(PrototypeIdSerializer<SourcePortPrototype>))]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string OutputHighPort = "OutputHigh";
|
public ProtoId<SourcePortPrototype> OutputHighPort = "OutputHigh";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the falling edge output port.
|
/// Name of the falling edge output port.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("outputLowPort", customTypeSerializer: typeof(PrototypeIdSerializer<SourcePortPrototype>))]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string OutputLowPort = "OutputLow";
|
public ProtoId<SourcePortPrototype> OutputLowPort = "OutputLow";
|
||||||
|
|
||||||
// Initial state
|
// Initial state
|
||||||
[ViewVariables]
|
[DataField]
|
||||||
public SignalState State = SignalState.Low;
|
public SignalState State = SignalState.Low;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,62 +2,61 @@ using Content.Server.DeviceLinking.Systems;
|
|||||||
using Content.Shared.DeviceLinking;
|
using Content.Shared.DeviceLinking;
|
||||||
using Content.Shared.Tools;
|
using Content.Shared.Tools;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Server.DeviceLinking.Components;
|
namespace Content.Server.DeviceLinking.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A logic gate that sets its output port by doing an operation on its 2 input ports, A and B.
|
/// A logic gate that sets its output port by doing an operation on its 2 input ports, A and B.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent, Access(typeof(LogicGateSystem))]
|
||||||
[Access(typeof(LogicGateSystem))]
|
|
||||||
public sealed partial class LogicGateComponent : Component
|
public sealed partial class LogicGateComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The logic gate operation to use.
|
/// The logic gate operation to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("gate")]
|
[DataField]
|
||||||
public LogicGate Gate = LogicGate.Or;
|
public LogicGate Gate = LogicGate.Or;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tool quality to use for cycling logic gate operations.
|
/// Tool quality to use for cycling logic gate operations.
|
||||||
/// Cannot be pulsing since linking uses that.
|
/// Cannot be pulsing since linking uses that.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("cycleQuality", customTypeSerializer: typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string CycleQuality = "Screwing";
|
public ProtoId<ToolQualityPrototype> CycleQuality = "Screwing";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sound played when cycling logic gate operations.
|
/// Sound played when cycling logic gate operations.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("cycleSound")]
|
[DataField]
|
||||||
public SoundSpecifier CycleSound = new SoundPathSpecifier("/Audio/Machines/lightswitch.ogg");
|
public SoundSpecifier CycleSound = new SoundPathSpecifier("/Audio/Machines/lightswitch.ogg");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the first input port.
|
/// Name of the first input port.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("inputPortA", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string InputPortA = "InputA";
|
public ProtoId<SinkPortPrototype> InputPortA = "InputA";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the second input port.
|
/// Name of the second input port.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("inputPortB", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string InputPortB = "InputB";
|
public ProtoId<SinkPortPrototype> InputPortB = "InputB";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the output port.
|
/// Name of the output port.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("outputPort", customTypeSerializer: typeof(PrototypeIdSerializer<SourcePortPrototype>))]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string OutputPort = "Output";
|
public ProtoId<SourcePortPrototype> OutputPort = "Output";
|
||||||
|
|
||||||
// Initial state
|
// Initial state
|
||||||
[ViewVariables]
|
[DataField]
|
||||||
public SignalState StateA = SignalState.Low;
|
public SignalState StateA = SignalState.Low;
|
||||||
|
|
||||||
[ViewVariables]
|
[DataField]
|
||||||
public SignalState StateB = SignalState.Low;
|
public SignalState StateB = SignalState.Low;
|
||||||
|
|
||||||
[ViewVariables]
|
[DataField]
|
||||||
public bool LastOutput;
|
public bool LastOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
using Content.Server.DeviceLinking.Systems;
|
||||||
|
using Content.Shared.DeviceLinking;
|
||||||
|
using Content.Shared.Tools;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||||
|
|
||||||
|
namespace Content.Server.DeviceLinking.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A power sensor checks the power network it's anchored to.
|
||||||
|
/// Has 2 ports for when it is charging or discharging. They should never both be high.
|
||||||
|
/// Requires <see cref="PowerSwitchableComponent"/> to function.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, Access(typeof(PowerSensorSystem))]
|
||||||
|
public sealed partial class PowerSensorComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to check the power network's input or output battery stats.
|
||||||
|
/// Useful when working with SMESes where input and output can both be important.
|
||||||
|
/// Or with APCs where there is no output and only input.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public bool Output;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tool quality to use for switching between input and output.
|
||||||
|
/// Cannot be pulsing since linking uses that.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public ProtoId<ToolQualityPrototype> SwitchQuality = "Screwing";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sound played when switching between input and output.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public SoundSpecifier SwitchSound = new SoundPathSpecifier("/Audio/Machines/lightswitch.ogg");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the port set when the network is charging power.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public ProtoId<SourcePortPrototype> ChargingPort = "PowerCharging";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the port set when the network is discharging power.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public ProtoId<SourcePortPrototype> DischargingPort = "PowerDischarging";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How long to wait before checking the power network.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public TimeSpan CheckDelay = TimeSpan.FromSeconds(1);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Time at which power will be checked.
|
||||||
|
/// </summary>
|
||||||
|
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public TimeSpan NextCheck = TimeSpan.Zero;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Charge the network was at, at the last check.
|
||||||
|
/// Charging/discharging is derived from this.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public float LastCharge;
|
||||||
|
|
||||||
|
// Initial state
|
||||||
|
[DataField]
|
||||||
|
public bool ChargingState;
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public bool DischargingState;
|
||||||
|
}
|
||||||
@@ -3,8 +3,9 @@ using Content.Server.DeviceNetwork;
|
|||||||
using Content.Shared.DeviceLinking;
|
using Content.Shared.DeviceLinking;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Tools;
|
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
|
using Content.Shared.Timing;
|
||||||
|
using Content.Shared.Tools;
|
||||||
using Content.Shared.Tools.Systems;
|
using Content.Shared.Tools.Systems;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
@@ -19,6 +20,7 @@ public sealed class LogicGateSystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||||
[Dependency] private readonly SharedToolSystem _tool = default!;
|
[Dependency] private readonly SharedToolSystem _tool = default!;
|
||||||
|
[Dependency] private readonly UseDelaySystem _useDelay = default!;
|
||||||
|
|
||||||
private readonly int GateCount = Enum.GetValues(typeof(LogicGate)).Length;
|
private readonly int GateCount = Enum.GetValues(typeof(LogicGate)).Length;
|
||||||
|
|
||||||
@@ -71,6 +73,10 @@ public sealed class LogicGateSystem : EntitySystem
|
|||||||
if (args.Handled || !_tool.HasQuality(args.Used, comp.CycleQuality))
|
if (args.Handled || !_tool.HasQuality(args.Used, comp.CycleQuality))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// no sound spamming
|
||||||
|
if (TryComp<UseDelayComponent>(uid, out var useDelay) && _useDelay.ActiveDelay(uid, useDelay))
|
||||||
|
return;
|
||||||
|
|
||||||
// cycle through possible gates
|
// cycle through possible gates
|
||||||
var gate = (int) comp.Gate;
|
var gate = (int) comp.Gate;
|
||||||
gate = ++gate % GateCount;
|
gate = ++gate % GateCount;
|
||||||
@@ -84,6 +90,8 @@ public sealed class LogicGateSystem : EntitySystem
|
|||||||
var msg = Loc.GetString("logic-gate-cycle", ("gate", comp.Gate.ToString().ToUpper()));
|
var msg = Loc.GetString("logic-gate-cycle", ("gate", comp.Gate.ToString().ToUpper()));
|
||||||
_popup.PopupEntity(msg, uid, args.User);
|
_popup.PopupEntity(msg, uid, args.User);
|
||||||
_appearance.SetData(uid, LogicGateVisuals.Gate, comp.Gate);
|
_appearance.SetData(uid, LogicGateVisuals.Gate, comp.Gate);
|
||||||
|
|
||||||
|
_useDelay.BeginDelay(uid, useDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSignalReceived(EntityUid uid, LogicGateComponent comp, ref SignalReceivedEvent args)
|
private void OnSignalReceived(EntityUid uid, LogicGateComponent comp, ref SignalReceivedEvent args)
|
||||||
|
|||||||
140
Content.Server/DeviceLinking/Systems/PowerSensorSystem.cs
Normal file
140
Content.Server/DeviceLinking/Systems/PowerSensorSystem.cs
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
using Content.Server.DeviceLinking.Components;
|
||||||
|
using Content.Server.DeviceNetwork;
|
||||||
|
using Content.Server.NodeContainer;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
|
using Content.Server.Power.Nodes;
|
||||||
|
using Content.Server.Power.NodeGroups;
|
||||||
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Popups;
|
||||||
|
using Content.Shared.Power.Generator;
|
||||||
|
using Content.Shared.Timing;
|
||||||
|
using Content.Shared.Tools;
|
||||||
|
using Content.Shared.Tools.Systems;
|
||||||
|
using Robust.Shared.Audio.Systems;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
|
namespace Content.Server.DeviceLinking.Systems;
|
||||||
|
|
||||||
|
public sealed class PowerSensorSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly DeviceLinkSystem _deviceLink = default!;
|
||||||
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
|
[Dependency] private readonly PowerNetSystem _powerNet = default!;
|
||||||
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||||
|
[Dependency] private readonly SharedToolSystem _tool = default!;
|
||||||
|
[Dependency] private readonly UseDelaySystem _useDelay = default!;
|
||||||
|
|
||||||
|
private EntityQuery<NodeContainerComponent> _nodeQuery;
|
||||||
|
private EntityQuery<TransformComponent> _xformQuery;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
_nodeQuery = GetEntityQuery<NodeContainerComponent>();
|
||||||
|
_xformQuery = GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<PowerSensorComponent, ComponentInit>(OnInit);
|
||||||
|
SubscribeLocalEvent<PowerSensorComponent, ExaminedEvent>(OnExamined);
|
||||||
|
SubscribeLocalEvent<PowerSensorComponent, InteractUsingEvent>(OnInteractUsing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(float deltaTime)
|
||||||
|
{
|
||||||
|
var query = EntityQueryEnumerator<PowerSensorComponent>();
|
||||||
|
while (query.MoveNext(out var uid, out var comp))
|
||||||
|
{
|
||||||
|
var now = _timing.CurTime;
|
||||||
|
if (comp.NextCheck > now)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
comp.NextCheck = now + comp.CheckDelay;
|
||||||
|
UpdateOutputs(uid, comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnInit(EntityUid uid, PowerSensorComponent comp, ComponentInit args)
|
||||||
|
{
|
||||||
|
_deviceLink.EnsureSourcePorts(uid, comp.ChargingPort, comp.DischargingPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnExamined(EntityUid uid, PowerSensorComponent comp, ExaminedEvent args)
|
||||||
|
{
|
||||||
|
if (!args.IsInDetailsRange)
|
||||||
|
return;
|
||||||
|
|
||||||
|
args.PushMarkup(Loc.GetString("power-sensor-examine", ("output", comp.Output)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnInteractUsing(EntityUid uid, PowerSensorComponent comp, InteractUsingEvent args)
|
||||||
|
{
|
||||||
|
if (args.Handled || !_tool.HasQuality(args.Used, comp.SwitchQuality))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// no sound spamming
|
||||||
|
if (TryComp<UseDelayComponent>(uid, out var useDelay) && _useDelay.ActiveDelay(uid, useDelay))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// switch between input and output mode.
|
||||||
|
comp.Output = !comp.Output;
|
||||||
|
|
||||||
|
// since the battery to be checked changed the output probably has too, update it
|
||||||
|
UpdateOutputs(uid, comp);
|
||||||
|
|
||||||
|
// notify the user
|
||||||
|
_audio.PlayPvs(comp.SwitchSound, uid);
|
||||||
|
var msg = Loc.GetString("power-sensor-switch", ("output", comp.Output));
|
||||||
|
_popup.PopupEntity(msg, uid, args.User);
|
||||||
|
|
||||||
|
_useDelay.BeginDelay(uid, useDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateOutputs(EntityUid uid, PowerSensorComponent comp)
|
||||||
|
{
|
||||||
|
// get power stats on the power network that's been switched to
|
||||||
|
var powerSwitchable = Comp<PowerSwitchableComponent>(uid);
|
||||||
|
var cable = powerSwitchable.Cables[powerSwitchable.ActiveIndex];
|
||||||
|
var nodeContainer = Comp<NodeContainerComponent>(uid);
|
||||||
|
var deviceNode = (CableDeviceNode) nodeContainer.Nodes[cable.Node];
|
||||||
|
|
||||||
|
var charge = 0f;
|
||||||
|
var chargingState = false;
|
||||||
|
var dischargingState = false;
|
||||||
|
|
||||||
|
// update state based on the power stats retrieved from the selected power network
|
||||||
|
var xform = _xformQuery.GetComponent(uid);
|
||||||
|
_mapManager.TryGetGrid(xform.GridUid, out var grid);
|
||||||
|
var cables = deviceNode.GetReachableNodes(xform, _nodeQuery, _xformQuery, grid, EntityManager);
|
||||||
|
foreach (var node in cables)
|
||||||
|
{
|
||||||
|
if (node.NodeGroup == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var group = (IBasePowerNet) node.NodeGroup;
|
||||||
|
var stats = _powerNet.GetNetworkStatistics(group.NetworkNode);
|
||||||
|
charge = comp.Output ? stats.OutStorageCurrent : stats.InStorageCurrent;
|
||||||
|
chargingState = charge > comp.LastCharge;
|
||||||
|
dischargingState = charge < comp.LastCharge;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
comp.LastCharge = charge;
|
||||||
|
|
||||||
|
// send new signals if changed
|
||||||
|
if (comp.ChargingState != chargingState)
|
||||||
|
{
|
||||||
|
comp.ChargingState = chargingState;
|
||||||
|
_deviceLink.SendSignal(uid, comp.ChargingPort, chargingState);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (comp.DischargingState != dischargingState)
|
||||||
|
{
|
||||||
|
comp.DischargingState = dischargingState;
|
||||||
|
_deviceLink.SendSignal(uid, comp.DischargingPort, dischargingState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,15 @@
|
|||||||
logic-gate-examine = It is currently {INDEFINITE($gate)} {$gate} gate.
|
logic-gate-examine = It is currently {INDEFINITE($gate)} {$gate} gate.
|
||||||
|
|
||||||
logic-gate-cycle = Switched to {INDEFINITE($gate)} {$gate} gate
|
logic-gate-cycle = Switched to {INDEFINITE($gate)} {$gate} gate
|
||||||
|
|
||||||
|
power-sensor-examine = It is currently checking the network's {$output ->
|
||||||
|
[true] output
|
||||||
|
*[false] input
|
||||||
|
} battery.
|
||||||
|
power-sensor-voltage-examine = It is checking the {$voltage} power network.
|
||||||
|
|
||||||
|
power-sensor-switch = Switched to checking the network's {$output ->
|
||||||
|
[true] output
|
||||||
|
*[false] input
|
||||||
|
} battery.
|
||||||
|
power-sensor-voltage-switch = Switched network to {$voltage}!
|
||||||
|
|||||||
@@ -60,3 +60,9 @@ signal-port-description-pulse = This port is invoked when a bound anomaly is pul
|
|||||||
|
|
||||||
signal-port-name-supercrit = Supercritical
|
signal-port-name-supercrit = Supercritical
|
||||||
signal-port-description-supercrit = This port is invoked when a bound anomaly explode after supercrit state.
|
signal-port-description-supercrit = This port is invoked when a bound anomaly explode after supercrit state.
|
||||||
|
|
||||||
|
signal-port-name-power-charging = Charging
|
||||||
|
signal-port-description-power-charging = This port is invoked with HIGH when the battery is gaining charge and LOW when not.
|
||||||
|
|
||||||
|
signal-port-name-power-discharging = Discharging
|
||||||
|
signal-port-description-power-discharging = This port is invoked with HIGH when the battery is losing charge and LOW when not.
|
||||||
|
|||||||
@@ -139,3 +139,13 @@
|
|||||||
id: Supercritical
|
id: Supercritical
|
||||||
name: signal-port-name-supercrit
|
name: signal-port-name-supercrit
|
||||||
description: signal-port-description-supercrit
|
description: signal-port-description-supercrit
|
||||||
|
|
||||||
|
- type: sourcePort
|
||||||
|
id: PowerCharging
|
||||||
|
name: signal-port-name-power-charging
|
||||||
|
description: signal-port-description-power-charging
|
||||||
|
|
||||||
|
- type: sourcePort
|
||||||
|
id: PowerDischarging
|
||||||
|
name: signal-port-name-power-discharging
|
||||||
|
description: signal-port-description-power-discharging
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
- state: or
|
- state: or
|
||||||
map: [ "enum.LogicGateLayers.Gate" ]
|
map: [ "enum.LogicGateLayers.Gate" ]
|
||||||
- type: LogicGate
|
- type: LogicGate
|
||||||
|
- type: UseDelay
|
||||||
|
delay: 0.5
|
||||||
- type: DeviceLinkSink
|
- type: DeviceLinkSink
|
||||||
ports:
|
ports:
|
||||||
- InputA
|
- InputA
|
||||||
@@ -66,3 +68,46 @@
|
|||||||
- type: Construction
|
- type: Construction
|
||||||
graph: LogicGate
|
graph: LogicGate
|
||||||
node: edge_detector
|
node: edge_detector
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: BaseLogicItem
|
||||||
|
id: PowerSensor
|
||||||
|
name: power sensor
|
||||||
|
description: Generates signals in response to powernet changes. Can be cycled between cable voltages.
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
state: power_sensor
|
||||||
|
- type: PowerSensor
|
||||||
|
- type: PowerSwitchable
|
||||||
|
examineText: power-sensor-voltage-examine
|
||||||
|
switchText: power-sensor-voltage-switch
|
||||||
|
cables:
|
||||||
|
- voltage: HV
|
||||||
|
node: hv
|
||||||
|
- voltage: MV
|
||||||
|
node: mv
|
||||||
|
- voltage: LV
|
||||||
|
node: lv
|
||||||
|
- type: UseDelay
|
||||||
|
delay: 1
|
||||||
|
- type: NodeContainer
|
||||||
|
examinable: true
|
||||||
|
nodes:
|
||||||
|
hv:
|
||||||
|
!type:CableDeviceNode
|
||||||
|
nodeGroupID: HVPower
|
||||||
|
mv:
|
||||||
|
!type:CableDeviceNode
|
||||||
|
nodeGroupID: MVPower
|
||||||
|
enabled: false
|
||||||
|
lv:
|
||||||
|
!type:CableDeviceNode
|
||||||
|
nodeGroupID: Apc
|
||||||
|
enabled: false
|
||||||
|
- type: DeviceLinkSource
|
||||||
|
ports:
|
||||||
|
- PowerCharging
|
||||||
|
- PowerDischarging
|
||||||
|
- type: Construction
|
||||||
|
graph: LogicGate
|
||||||
|
node: power_sensor
|
||||||
|
|||||||
@@ -20,7 +20,22 @@
|
|||||||
- material: Cable
|
- material: Cable
|
||||||
amount: 2
|
amount: 2
|
||||||
doAfter: 1
|
doAfter: 1
|
||||||
|
- to: power_sensor
|
||||||
|
steps:
|
||||||
|
- material: Steel
|
||||||
|
amount: 3
|
||||||
|
doAfter: 1
|
||||||
|
- material: Cable
|
||||||
|
amount: 2
|
||||||
|
doAfter: 1
|
||||||
|
- tag: Multitool
|
||||||
|
icon:
|
||||||
|
sprite: Objects/Tools/multitool.rsi
|
||||||
|
state: icon
|
||||||
|
name: a multitool
|
||||||
- node: logic_gate
|
- node: logic_gate
|
||||||
entity: LogicGate
|
entity: LogicGate
|
||||||
- node: edge_detector
|
- node: edge_detector
|
||||||
entity: EdgeDetector
|
entity: EdgeDetector
|
||||||
|
- node: power_sensor
|
||||||
|
entity: PowerSensor
|
||||||
|
|||||||
@@ -30,3 +30,14 @@
|
|||||||
description: An edge detector for signals.
|
description: An edge detector for signals.
|
||||||
icon: { sprite: Objects/Devices/gates.rsi, state: edge_detector }
|
icon: { sprite: Objects/Devices/gates.rsi, state: edge_detector }
|
||||||
objectType: Item
|
objectType: Item
|
||||||
|
|
||||||
|
- type: construction
|
||||||
|
name: power sensor
|
||||||
|
id: PowerSensor
|
||||||
|
graph: LogicGate
|
||||||
|
startNode: start
|
||||||
|
targetNode: power_sensor
|
||||||
|
category: construction-category-tools
|
||||||
|
description: A power network checking device for signals.
|
||||||
|
icon: { sprite: Objects/Devices/gates.rsi, state: power_sensor }
|
||||||
|
objectType: Item
|
||||||
|
|||||||
@@ -33,6 +33,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "or_icon"
|
"name": "or_icon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "power_sensor"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Resources/Textures/Objects/Devices/gates.rsi/power_sensor.png
Normal file
BIN
Resources/Textures/Objects/Devices/gates.rsi/power_sensor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
Reference in New Issue
Block a user