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
This commit is contained in:
@@ -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<SiliconLawBoundComponent>(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<StationAiHolderComponent>(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<MovementRelayTargetComponent>(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"),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user