From 0b8194723eed166556267807496142b0569c798e Mon Sep 17 00:00:00 2001 From: "pa.pecherskij" Date: Thu, 12 Sep 2024 18:23:49 +0300 Subject: [PATCH] extracted ShowDeviceNotRespondingPopup, reverted airlocks not opening/closing when ai wire was cut --- .../SharedStationAiSystem.Airlock.cs | 8 +++--- .../StationAi/SharedStationAiSystem.Held.cs | 25 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs index 94fa935f5e4a0c..1ad83c7de89c5e 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs @@ -27,14 +27,14 @@ private void OnAirlockBolt(EntityUid ent, DoorBoltComponent component, StationAi { if (component.BoltWireCut) { - _popup.PopupClient(Loc.GetString("ai-device-not-responding"), args.User, PopupType.MediumCaution); + ShowDeviceNotRespondingPopup(args.User); return; } var setResult = _doors.TrySetBoltDown((ent, component), args.Bolted, args.User, predicted: true); if (!setResult) { - _popup.PopupClient(Loc.GetString("ai-device-not-responding"), args.User, PopupType.MediumCaution); + ShowDeviceNotRespondingPopup(args.User); } } @@ -45,7 +45,7 @@ private void OnAirlockEmergencyAccess(EntityUid ent, AirlockComponent component, { if (!PowerReceiver.IsPowered(ent)) { - _popup.PopupClient(Loc.GetString("ai-device-not-responding"), args.User, PopupType.MediumCaution); + ShowDeviceNotRespondingPopup(args.User); return; } @@ -67,7 +67,7 @@ private void OnElectrified(EntityUid ent, ElectrifiedComponent component, Statio || !PowerReceiver.IsPowered(ent) ) { - _popup.PopupClient(Loc.GetString("ai-device-not-responding"), args.User, PopupType.MediumCaution); + ShowDeviceNotRespondingPopup(args.User); return; } diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs index 501ff8e46fb537..31dc3efd52a7de 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs @@ -119,16 +119,22 @@ private void OnMessageAttempt(BoundUserInterfaceMessageAttempt ev) if (whitelistComponent is { Enabled: false }) { ev.Cancel(); - _popup.PopupClient(Loc.GetString("ai-device-not-responding"), ev.Actor, PopupType.MediumCaution); + ShowDeviceNotRespondingPopup(ev.Actor); } } private void OnHeldInteraction(Entity ent, ref InteractionAttemptEvent args) { - // Cancel if it's not us or something with a whitelist. - args.Cancelled = ent.Owner != args.Target && - args.Target != null && - !HasComp(args.Target); + StationAiWhitelistComponent? whitelistComponent = null; + // Cancel if it's not us or something with a whitelist, or whitelist is disabled. + args.Cancelled = ent.Owner != args.Target + && args.Target != null + && (!TryComp(args.Target, out whitelistComponent) + || !whitelistComponent.Enabled); + if (whitelistComponent is { Enabled: false }) + { + ShowDeviceNotRespondingPopup(ent.Owner); + } } private void OnTargetVerbs(Entity ent, ref GetVerbsEvent args) @@ -143,7 +149,7 @@ private void OnTargetVerbs(Entity ent, ref GetVerbs var user = args.User; if (!ent.Comp.Enabled) { - _popup.PopupClient(Loc.GetString("ai-device-not-responding"), user, PopupType.MediumCaution); + ShowDeviceNotRespondingPopup(user); return; } @@ -159,7 +165,7 @@ private void OnTargetVerbs(Entity ent, ref GetVerbs // no need to show menu if device is not powered. if (!PowerReceiver.IsPowered(ent.Owner)) { - _popup.PopupClient(Loc.GetString("ai-device-not-responding"), user, PopupType.MediumCaution); + ShowDeviceNotRespondingPopup(user); return; } @@ -175,6 +181,11 @@ private void OnTargetVerbs(Entity ent, ref GetVerbs }; args.Verbs.Add(verb); } + + private void ShowDeviceNotRespondingPopup(EntityUid toEntity) + { + _popup.PopupClient(Loc.GetString("ai-device-not-responding"), toEntity, PopupType.MediumCaution); + } } ///