From 9520e829de3511ebd0e3304fb8d03ab0440db7dd Mon Sep 17 00:00:00 2001 From: nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com> Date: Sat, 2 Nov 2024 15:21:10 +0200 Subject: [PATCH] Allow for the ai's laws to be changed from its core and eye (#32461) * Allow for the ai's laws to be changed from its core and eye * Address reviews --- .../Administration/Systems/AdminVerbSystem.cs | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.cs b/Content.Server/Administration/Systems/AdminVerbSystem.cs index 2ab27e4388..0640537f57 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.cs @@ -35,8 +35,10 @@ using Robust.Shared.Toolshed; using Robust.Shared.Utility; using System.Linq; using Content.Server.Silicons.Laws; +using Content.Shared.Movement.Components; using Content.Shared.Silicons.Laws.Components; using Robust.Server.Player; +using Content.Shared.Silicons.StationAi; using Robust.Shared.Physics.Components; using static Content.Shared.Configurable.ConfigurationComponent; @@ -345,7 +347,30 @@ namespace Content.Server.Administration.Systems Impact = LogImpact.Low }); - if (TryComp(args.Target, out var lawBoundComponent)) + // This logic is needed to be able to modify the AI's laws through its core and eye. + EntityUid? target = null; + SiliconLawBoundComponent? lawBoundComponent = null; + + if (TryComp(args.Target, out lawBoundComponent)) + { + target = args.Target; + } + // When inspecting the core we can find the entity with its laws by looking at the AiHolderComponent. + else if (TryComp(args.Target, out var holder) && holder.Slot.Item != null + && TryComp(holder.Slot.Item, out lawBoundComponent)) + { + target = holder.Slot.Item.Value; + // For the eye we can find the entity with its laws as the source of the movement relay since the eye + // is just a proxy for it to move around and look around the station. + } + else if (TryComp(args.Target, out var relay) + && TryComp(relay.Source, out lawBoundComponent)) + { + target = relay.Source; + + } + + if (lawBoundComponent != null && target != null) { args.Verbs.Add(new Verb() { @@ -359,7 +384,7 @@ namespace Content.Server.Administration.Systems return; } _euiManager.OpenEui(ui, session); - ui.UpdateLaws(lawBoundComponent, args.Target); + ui.UpdateLaws(lawBoundComponent, target.Value); }, Icon = new SpriteSpecifier.Rsi(new ResPath("/Textures/Interface/Actions/actions_borg.rsi"), "state-laws"), }); -- 2.51.2