From 7b9a36e4b6c06164abe32ee7487e0635d1fdc6fe Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Fri, 18 Aug 2023 09:18:07 +0300 Subject: [PATCH] Logic stuff (#318) * Logic stuff * Update logic gate appearance on init * Add components * Move port * Fix --- .../DeviceLinking/Systems/LogicGateSystem.cs | 4 +++- .../Light/Components/PoweredLightComponent.cs | 3 +++ .../Light/EntitySystems/PoweredLightSystem.cs | 11 +++++++++++ Resources/Prototypes/DeviceLinking/source_ports.yml | 6 ++++++ .../Entities/Structures/Lighting/base_lighting.yml | 6 ++++++ .../Entities/Structures/Lighting/ground_lighting.yml | 3 +++ 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Content.Server/DeviceLinking/Systems/LogicGateSystem.cs b/Content.Server/DeviceLinking/Systems/LogicGateSystem.cs index 598d5a2725..60ab4712ff 100644 --- a/Content.Server/DeviceLinking/Systems/LogicGateSystem.cs +++ b/Content.Server/DeviceLinking/Systems/LogicGateSystem.cs @@ -44,7 +44,7 @@ public sealed class LogicGateSystem : EntitySystem } if (comp.StateB == SignalState.Momentary) { - comp.StateB = SignalState.High; + comp.StateB = SignalState.Low; } // output most likely changed so update it @@ -56,6 +56,8 @@ public sealed class LogicGateSystem : EntitySystem { _deviceLink.EnsureSinkPorts(uid, comp.InputPortA, comp.InputPortB); _deviceLink.EnsureSourcePorts(uid, comp.OutputPort); + + _appearance.SetData(uid, LogicGateVisuals.Gate, comp.Gate); // WD } private void OnExamined(EntityUid uid, LogicGateComponent comp, ExaminedEvent args) diff --git a/Content.Server/Light/Components/PoweredLightComponent.cs b/Content.Server/Light/Components/PoweredLightComponent.cs index 489a49eec2..fd331f459c 100644 --- a/Content.Server/Light/Components/PoweredLightComponent.cs +++ b/Content.Server/Light/Components/PoweredLightComponent.cs @@ -63,6 +63,9 @@ namespace Content.Server.Light.Components [DataField("togglePort", customTypeSerializer: typeof(PrototypeIdSerializer))] public string TogglePort = "Toggle"; + [DataField("statusPort", customTypeSerializer: typeof(PrototypeIdSerializer))] + public string StatusPort = "LightStatus"; + /// /// How long it takes to eject a bulb from this /// diff --git a/Content.Server/Light/EntitySystems/PoweredLightSystem.cs b/Content.Server/Light/EntitySystems/PoweredLightSystem.cs index 6aea340e56..dbd9c35620 100644 --- a/Content.Server/Light/EntitySystems/PoweredLightSystem.cs +++ b/Content.Server/Light/EntitySystems/PoweredLightSystem.cs @@ -2,6 +2,7 @@ using Content.Server.Administration.Logs; using Content.Server.Clothing.Components; using Content.Server.DeviceLinking.Events; using Content.Server.DeviceLinking.Systems; +using Content.Server.DeviceLinking.Components; using Content.Server.DeviceNetwork; using Content.Server.DeviceNetwork.Systems; using Content.Server.Emp; @@ -79,6 +80,7 @@ namespace Content.Server.Light.EntitySystems { light.LightBulbContainer = _containerSystem.EnsureContainer(uid, LightBulbContainer); _signalSystem.EnsureSinkPorts(uid, light.OnPort, light.OffPort, light.TogglePort); + _signalSystem.EnsureSourcePorts(uid, light.StatusPort); // WD } private void OnMapInit(EntityUid uid, PoweredLightComponent light, MapInitEvent args) @@ -421,6 +423,15 @@ namespace Content.Server.Light.EntitySystems return; 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); } diff --git a/Resources/Prototypes/DeviceLinking/source_ports.yml b/Resources/Prototypes/DeviceLinking/source_ports.yml index 152ca01c1e..fdbea673e9 100644 --- a/Resources/Prototypes/DeviceLinking/source_ports.yml +++ b/Resources/Prototypes/DeviceLinking/source_ports.yml @@ -154,3 +154,9 @@ id: ChemMasterSender name: Раздатчик description: Передатчик сигнала ХимМастера + +- type: sourcePort + id: LightStatus + name: Статус светильника + description: Этот порт вызывается всякий раз, когда меняется статус светильника + defaultLinks: [ Toggle ] diff --git a/Resources/Prototypes/Entities/Structures/Lighting/base_lighting.yml b/Resources/Prototypes/Entities/Structures/Lighting/base_lighting.yml index 667c5a139e..f5fa13e4e2 100644 --- a/Resources/Prototypes/Entities/Structures/Lighting/base_lighting.yml +++ b/Resources/Prototypes/Entities/Structures/Lighting/base_lighting.yml @@ -92,6 +92,9 @@ receiveFrequencyId: SmartLight - type: WirelessNetworkConnection range: 200 + - type: DeviceLinkSource + ports: + - LightStatus - type: DeviceLinkSink ports: - On @@ -287,6 +290,9 @@ on: base broken: broken burned: burned + - type: DeviceLinkSource + ports: + - LightStatus - type: DeviceLinkSink ports: - On diff --git a/Resources/Prototypes/Entities/Structures/Lighting/ground_lighting.yml b/Resources/Prototypes/Entities/Structures/Lighting/ground_lighting.yml index 6eda921ca4..fe5abf9365 100644 --- a/Resources/Prototypes/Entities/Structures/Lighting/ground_lighting.yml +++ b/Resources/Prototypes/Entities/Structures/Lighting/ground_lighting.yml @@ -95,6 +95,9 @@ receiveFrequencyId: SmartLight - type: WirelessNetworkConnection range: 200 + - type: DeviceLinkSource + ports: + - LightStatus - type: DeviceLinkSink ports: - On