From: Borsh <85323386+NeBorsh@users.noreply.github.com> Date: Sun, 14 Dec 2025 19:15:22 +0000 (+0300) Subject: Adding a random gate (#41627) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=6fc13a5875ea2cc7d46a4bcbc822cecef0dfd577;p=space-station-14.git 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 --- 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 @@ + + + + + + +