From 6fc13a5875ea2cc7d46a4bcbc822cecef0dfd577 Mon Sep 17 00:00:00 2001 From: Borsh <85323386+NeBorsh@users.noreply.github.com> Date: Sun, 14 Dec 2025 22:15:22 +0300 Subject: [PATCH] Adding a random gate (#41627) * Added random gate * minor edit * cleaning up my shit after trying to do something faster * new lines * some changes * joke * UI * Long Division * Dont use ctrl + x in 3 am * I hope these are the final touches * One thing, I don't know why * noname commit * no way, 1kk of code lines edit * sudo rm -rf ... and something there... * update * sometimes its sad --- .../DeviceLinking/Systems/RandomGateSystem.cs | 5 +++ .../UI/RandomGateBoundUserInterface.cs | 37 ++++++++++++++++++ .../UI/RandomGateSetupWindow.xaml | 19 +++++++++ .../UI/RandomGateSetupWindow.xaml.cs | 28 +++++++++++++ .../DeviceLinking/Systems/RandomGateSystem.cs | 32 +++++++++++++++ .../Components/RandomGateComponent.cs | 35 +++++++++++++++++ .../DeviceLinking/SharedRandomGateEvents.cs | 21 ++++++++++ .../Systems/SharedRandomGateSystem.cs | 35 +++++++++++++++++ .../Locale/en-US/deviceLinking/randomgate.ftl | 3 ++ .../en-US/machine-linking/receiver_ports.ftl | 3 ++ .../Prototypes/DeviceLinking/sink_ports.yml | 5 +++ .../Prototypes/Entities/Structures/gates.yml | 26 ++++++++++++ .../Construction/Graphs/tools/logic_gate.yml | 22 +++++++++++ .../Prototypes/Recipes/Construction/tools.yml | 8 ++++ .../Objects/Devices/gates.rsi/meta.json | 5 ++- .../Objects/Devices/gates.rsi/random_gate.png | Bin 0 -> 215 bytes 16 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 Content.Client/DeviceLinking/Systems/RandomGateSystem.cs create mode 100644 Content.Client/DeviceLinking/UI/RandomGateBoundUserInterface.cs create mode 100644 Content.Client/DeviceLinking/UI/RandomGateSetupWindow.xaml create mode 100644 Content.Client/DeviceLinking/UI/RandomGateSetupWindow.xaml.cs create mode 100644 Content.Server/DeviceLinking/Systems/RandomGateSystem.cs create mode 100644 Content.Shared/DeviceLinking/Components/RandomGateComponent.cs create mode 100644 Content.Shared/DeviceLinking/SharedRandomGateEvents.cs create mode 100644 Content.Shared/DeviceLinking/Systems/SharedRandomGateSystem.cs create mode 100644 Resources/Locale/en-US/deviceLinking/randomgate.ftl create mode 100644 Resources/Textures/Objects/Devices/gates.rsi/random_gate.png diff --git a/Content.Client/DeviceLinking/Systems/RandomGateSystem.cs b/Content.Client/DeviceLinking/Systems/RandomGateSystem.cs new file mode 100644 index 0000000000..db0d956c72 --- /dev/null +++ b/Content.Client/DeviceLinking/Systems/RandomGateSystem.cs @@ -0,0 +1,5 @@ +using Content.Shared.DeviceLinking.Systems; + +namespace Content.Client.DeviceLinking.Systems; + +public sealed class RandomGateSystem : SharedRandomGateSystem; diff --git a/Content.Client/DeviceLinking/UI/RandomGateBoundUserInterface.cs b/Content.Client/DeviceLinking/UI/RandomGateBoundUserInterface.cs new file mode 100644 index 0000000000..c8c97b84c6 --- /dev/null +++ b/Content.Client/DeviceLinking/UI/RandomGateBoundUserInterface.cs @@ -0,0 +1,37 @@ +using Content.Shared.DeviceLinking; +using JetBrains.Annotations; +using Robust.Client.UserInterface; + +namespace Content.Client.DeviceLinking.UI; + +[UsedImplicitly] +public sealed class RandomGateBoundUserInterface : BoundUserInterface +{ + private RandomGateSetupWindow? _window; + + public RandomGateBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { } + + protected override void Open() + { + base.Open(); + _window = this.CreateWindow(); + _window.OnApplyPressed += OnProbabilityChanged; + } + + private void OnProbabilityChanged(string value) + { + if (!float.TryParse(value, out var probability)) + return; + + SendPredictedMessage(new RandomGateProbabilityChangedMessage(probability)); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + if (state is not RandomGateBoundUserInterfaceState castState || _window == null) + return; + + _window.SetProbability(castState.SuccessProbability * 100); + } +} diff --git a/Content.Client/DeviceLinking/UI/RandomGateSetupWindow.xaml b/Content.Client/DeviceLinking/UI/RandomGateSetupWindow.xaml new file mode 100644 index 0000000000..d9273c9110 --- /dev/null +++ b/Content.Client/DeviceLinking/UI/RandomGateSetupWindow.xaml @@ -0,0 +1,19 @@ + + + + + + +