Logic stuff (#318)

* Logic stuff

* Update logic gate appearance on init

* Add components

* Move port

* Fix
This commit is contained in:
Aviu00
2023-08-18 09:18:07 +03:00
committed by Aviu00
parent 11cd6c7ac4
commit 7b9a36e4b6
6 changed files with 32 additions and 1 deletions

View File

@@ -44,7 +44,7 @@ public sealed class LogicGateSystem : EntitySystem
} }
if (comp.StateB == SignalState.Momentary) if (comp.StateB == SignalState.Momentary)
{ {
comp.StateB = SignalState.High; comp.StateB = SignalState.Low;
} }
// output most likely changed so update it // output most likely changed so update it
@@ -56,6 +56,8 @@ public sealed class LogicGateSystem : EntitySystem
{ {
_deviceLink.EnsureSinkPorts(uid, comp.InputPortA, comp.InputPortB); _deviceLink.EnsureSinkPorts(uid, comp.InputPortA, comp.InputPortB);
_deviceLink.EnsureSourcePorts(uid, comp.OutputPort); _deviceLink.EnsureSourcePorts(uid, comp.OutputPort);
_appearance.SetData(uid, LogicGateVisuals.Gate, comp.Gate); // WD
} }
private void OnExamined(EntityUid uid, LogicGateComponent comp, ExaminedEvent args) private void OnExamined(EntityUid uid, LogicGateComponent comp, ExaminedEvent args)

View File

@@ -63,6 +63,9 @@ namespace Content.Server.Light.Components
[DataField("togglePort", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))] [DataField("togglePort", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>))]
public string TogglePort = "Toggle"; public string TogglePort = "Toggle";
[DataField("statusPort", customTypeSerializer: typeof(PrototypeIdSerializer<SourcePortPrototype>))]
public string StatusPort = "LightStatus";
/// <summary> /// <summary>
/// How long it takes to eject a bulb from this /// How long it takes to eject a bulb from this
/// </summary> /// </summary>

View File

@@ -2,6 +2,7 @@ using Content.Server.Administration.Logs;
using Content.Server.Clothing.Components; using Content.Server.Clothing.Components;
using Content.Server.DeviceLinking.Events; using Content.Server.DeviceLinking.Events;
using Content.Server.DeviceLinking.Systems; using Content.Server.DeviceLinking.Systems;
using Content.Server.DeviceLinking.Components;
using Content.Server.DeviceNetwork; using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Systems; using Content.Server.DeviceNetwork.Systems;
using Content.Server.Emp; using Content.Server.Emp;
@@ -79,6 +80,7 @@ namespace Content.Server.Light.EntitySystems
{ {
light.LightBulbContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, LightBulbContainer); light.LightBulbContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, LightBulbContainer);
_signalSystem.EnsureSinkPorts(uid, light.OnPort, light.OffPort, light.TogglePort); _signalSystem.EnsureSinkPorts(uid, light.OnPort, light.OffPort, light.TogglePort);
_signalSystem.EnsureSourcePorts(uid, light.StatusPort); // WD
} }
private void OnMapInit(EntityUid uid, PoweredLightComponent light, MapInitEvent args) private void OnMapInit(EntityUid uid, PoweredLightComponent light, MapInitEvent args)
@@ -421,6 +423,15 @@ namespace Content.Server.Light.EntitySystems
return; return;
light.On = !light.On; light.On = !light.On;
// WD START
var data = new NetworkPayload
{
{DeviceNetworkConstants.LogicState, light.On ? SignalState.High : SignalState.Low}
};
_signalSystem.InvokePort(uid, light.StatusPort, data);
// WD END
UpdateLight(uid, light); UpdateLight(uid, light);
} }

View File

@@ -154,3 +154,9 @@
id: ChemMasterSender id: ChemMasterSender
name: Раздатчик name: Раздатчик
description: Передатчик сигнала ХимМастера description: Передатчик сигнала ХимМастера
- type: sourcePort
id: LightStatus
name: Статус светильника
description: Этот порт вызывается всякий раз, когда меняется статус светильника
defaultLinks: [ Toggle ]

View File

@@ -92,6 +92,9 @@
receiveFrequencyId: SmartLight receiveFrequencyId: SmartLight
- type: WirelessNetworkConnection - type: WirelessNetworkConnection
range: 200 range: 200
- type: DeviceLinkSource
ports:
- LightStatus
- type: DeviceLinkSink - type: DeviceLinkSink
ports: ports:
- On - On
@@ -287,6 +290,9 @@
on: base on: base
broken: broken broken: broken
burned: burned burned: burned
- type: DeviceLinkSource
ports:
- LightStatus
- type: DeviceLinkSink - type: DeviceLinkSink
ports: ports:
- On - On

View File

@@ -95,6 +95,9 @@
receiveFrequencyId: SmartLight receiveFrequencyId: SmartLight
- type: WirelessNetworkConnection - type: WirelessNetworkConnection
range: 200 range: 200
- type: DeviceLinkSource
ports:
- LightStatus
- type: DeviceLinkSink - type: DeviceLinkSink
ports: ports:
- On - On