From c394940072805190c40d53c42de828fa24a33677 Mon Sep 17 00:00:00 2001 From: RedFoxIV <38788538+RedFoxIV@users.noreply.github.com> Date: Thu, 26 Dec 2024 02:49:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B2=D1=81=D0=B5=D0=B3=D0=BE=20=D0=BB=D0=B8?= =?UTF-8?q?=D1=88=D1=8C=20=D0=B2=D0=BE=D1=81=D0=B5=D0=BC=D1=8C=20=D0=BC?= =?UTF-8?q?=D0=B8=D0=BD=D1=83=D1=82=20=D0=BB=D0=B5=D1=82=D0=B8=D1=82=20?= =?UTF-8?q?=D0=B1=D0=B5=D0=BA=D0=B4=D1=83=D1=80=20=D0=B2=20=D1=80=D0=B5?= =?UTF-8?q?=D0=BF=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChristmasLights/ChristmasLightsSystem.cs | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/Content.Client/_White/Misc/ChristmasLights/ChristmasLightsSystem.cs b/Content.Client/_White/Misc/ChristmasLights/ChristmasLightsSystem.cs index dc2b9f6dbf..560fa0d1ee 100644 --- a/Content.Client/_White/Misc/ChristmasLights/ChristmasLightsSystem.cs +++ b/Content.Client/_White/Misc/ChristmasLights/ChristmasLightsSystem.cs @@ -93,17 +93,8 @@ private void OnChristmasLightsVerbs(EntityUid uid, ChristmasLightsComponent comp ClientExclusive = true, CloseMenu = false, Act = () => { - if (!CanInteract(uid, args.User)) - return; - // can't move this into shared without a great deal of effort because of reliance on nodes. - // Nodes only exist in Content.Server, which is, frankly, fucking retarded. - _audio.PlayLocal(comp.ButtonSound, uid, args.User); - if (HasComp(args.Target)) - { - _popup.PopupClient(_loc.GetString("christmas-lights-unresponsive"), uid, args.User); - return; - } - RaiseNetworkEvent(new ChangeChristmasLightsModeAttemptEvent(GetNetEntity(args.Target))); + if(TryInteract(uid, args.User, comp)) + RaiseNetworkEvent(new ChangeChristmasLightsModeAttemptEvent(GetNetEntity(args.Target))); } }); args.Verbs.Add( @@ -115,19 +106,26 @@ private void OnChristmasLightsVerbs(EntityUid uid, ChristmasLightsComponent comp ClientExclusive = true, CloseMenu = false, Act = () =>{ - if(!CanInteract(uid, args.User)) - return; - _audio.PlayLocal(comp.ButtonSound, uid, args.User); - if(HasComp(args.Target)) - { - _popup.PopupClient(_loc.GetString("christmas-lights-unresponsive"), uid, args.User); - return; - } - RaiseNetworkEvent(new ChangeChristmasLightsBrightnessAttemptEvent(GetNetEntity(args.Target))); + if(TryInteract(uid, args.User, comp)) + RaiseNetworkEvent(new ChangeChristmasLightsBrightnessAttemptEvent(GetNetEntity(args.Target))); } }); } + private bool TryInteract(EntityUid uid, EntityUid user, ChristmasLightsComponent comp) + { + if (!CanInteract(uid, user)) + return false; + // can't move this into shared without a great deal of effort because of reliance on nodes. + // Nodes only exist in Content.Server, which is, frankly, fucking retarded. + _audio.PlayLocal(comp.ButtonSound, uid, user); + if (HasComp(uid)) + { + _popup.PopupClient(_loc.GetString("christmas-lights-unresponsive"), uid, user); + return false; + } + return true; + }