From b5af42f4ba95066ba5444b7cb95c3f3c5b772328 Mon Sep 17 00:00:00 2001 From: RevengenRat <138193222+Ratyyy@users.noreply.github.com> Date: Sun, 8 Sep 2024 22:42:29 +0300 Subject: [PATCH 1/4] custom ai law --- .../CustomAILaw/CustomAiLawBoardComponent.cs | 7 +++ .../ADT/CustomAILaw/CustomAiLawBoardSystem.cs | 41 ++++++++++++++++ Content.Server/Silicons/Laws/SiliconLawEui.cs | 8 ++-- .../Silicons/Laws/SiliconLawSystem.cs | 48 +++++++++++++++++-- .../Device/Circuitboards/aicustomlaw.ftl | 2 + .../administration/ui/silicon-law-ui.ftl | 2 +- .../Devices/Circuitboards/aicustomlaw.yml | 13 +++++ 7 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 Content.Server/ADT/CustomAILaw/CustomAiLawBoardComponent.cs create mode 100644 Content.Server/ADT/CustomAILaw/CustomAiLawBoardSystem.cs create mode 100644 Resources/Locale/ru-RU/ADT/prototypes/Entities/Objects/Device/Circuitboards/aicustomlaw.ftl create mode 100644 Resources/Prototypes/ADT/Entities/Objects/Devices/Circuitboards/aicustomlaw.yml diff --git a/Content.Server/ADT/CustomAILaw/CustomAiLawBoardComponent.cs b/Content.Server/ADT/CustomAILaw/CustomAiLawBoardComponent.cs new file mode 100644 index 00000000000..ac4ea9ba879 --- /dev/null +++ b/Content.Server/ADT/CustomAILaw/CustomAiLawBoardComponent.cs @@ -0,0 +1,7 @@ +namespace Content.Server.ADT.CustomAiLawBoard; + +[RegisterComponent] +public sealed partial class CustomAiLawBoardComponent : Component +{ + +} diff --git a/Content.Server/ADT/CustomAILaw/CustomAiLawBoardSystem.cs b/Content.Server/ADT/CustomAILaw/CustomAiLawBoardSystem.cs new file mode 100644 index 00000000000..6f1ce0dfa2e --- /dev/null +++ b/Content.Server/ADT/CustomAILaw/CustomAiLawBoardSystem.cs @@ -0,0 +1,41 @@ +using Content.Shared.Interaction; +using Content.Shared.Tools.Systems; +using Content.Server.Silicons.Laws; +using Content.Shared.Silicons.Laws.Components; +using Content.Server.Administration.Managers; +using Content.Server.EUI; +using Robust.Server.Player; + +namespace Content.Server.ADT.CustomAiLawBoard; + +public sealed class CustomAiLawBoardSystem : EntitySystem +{ + [Dependency] private readonly SharedToolSystem _toolSystem = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly SiliconLawSystem _siliconLawSystem = default!; + [Dependency] private readonly IAdminManager _adminManager = default!; + [Dependency] private readonly EuiManager _euiManager = default!; + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnInteractUsing); + } + private void OnInteractUsing(EntityUid uid, CustomAiLawBoardComponent comp, InteractUsingEvent args) + { + if (args.Handled) + return; + + if (!_toolSystem.HasQuality(args.Used, SharedToolSystem.PulseQuality)) + return; + + if (!TryComp(uid, out var lawBoundComponent)) + return; + var ui = new SiliconLawEui(_siliconLawSystem, EntityManager, _adminManager); + if (!_playerManager.TryGetSessionByEntity(args.User, out var session)) + { + return; + } + _euiManager.OpenEui(ui, session); + ui.UpdateLaws(lawBoundComponent, args.Target); + } +} diff --git a/Content.Server/Silicons/Laws/SiliconLawEui.cs b/Content.Server/Silicons/Laws/SiliconLawEui.cs index d5a5c4f4091..a6853c3f1f5 100644 --- a/Content.Server/Silicons/Laws/SiliconLawEui.cs +++ b/Content.Server/Silicons/Laws/SiliconLawEui.cs @@ -32,8 +32,8 @@ public override EuiStateBase GetNewState() public void UpdateLaws(SiliconLawBoundComponent? lawBoundComponent, EntityUid player) { - if (!IsAllowed()) - return; + // if (!IsAllowed()) + // return; ADT Custom ai law var laws = _siliconLawSystem.GetLaws(player, lawBoundComponent); _laws = laws.Laws; @@ -48,8 +48,8 @@ public override void HandleMessage(EuiMessageBase msg) return; } - if (!IsAllowed()) - return; + // if (!IsAllowed()) + // return; ADT Custom ai law var player = _entityManager.GetEntity(message.Target); diff --git a/Content.Server/Silicons/Laws/SiliconLawSystem.cs b/Content.Server/Silicons/Laws/SiliconLawSystem.cs index 6b7df52a6eb..e91769f12d8 100644 --- a/Content.Server/Silicons/Laws/SiliconLawSystem.cs +++ b/Content.Server/Silicons/Laws/SiliconLawSystem.cs @@ -21,6 +21,35 @@ using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Toolshed; +using Content.Server.Antag; +using Content.Server.Communications; +using Content.Server.GameTicking.Rules.Components; +using Content.Server.Nuke; +using Content.Server.NukeOps; +using Content.Server.Popups; +using Content.Server.Roles; +using Content.Server.RoundEnd; +using Content.Server.Shuttles.Events; +using Content.Server.Shuttles.Systems; +using Content.Server.Station.Components; +using Content.Server.Store.Components; +using Content.Server.Store.Systems; +using Content.Shared.GameTicking.Components; +using Content.Shared.Mobs; +using Content.Shared.Mobs.Components; +using Content.Shared.NPC.Components; +using Content.Shared.NPC.Systems; +using Content.Shared.Nuke; +using Content.Shared.NukeOps; +using Content.Shared.Store; +using Content.Shared.Tag; +using Content.Shared.Zombies; +using Robust.Shared.Map; +using Robust.Shared.Random; +using Robust.Shared.Utility; +using System.Linq; +using Content.Shared.CombatMode.Pacification; +using Content.Shared.Store.Components; namespace Content.Server.Silicons.Laws; @@ -34,6 +63,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem [Dependency] private readonly UserInterfaceSystem _userInterface = default!; [Dependency] private readonly SharedStunSystem _stunSystem = default!; [Dependency] private readonly SharedRoleSystem _roles = default!; + [Dependency] private readonly NpcFactionSystem _faction = default!; /// public override void Initialize() @@ -275,7 +305,6 @@ public void SetLaws(List newLaws, EntityUid target) { if (!TryComp(target, out var component)) return; - if (component.Lawset == null) component.Lawset = new SiliconLawset(); @@ -286,17 +315,30 @@ public void SetLaws(List newLaws, EntityUid target) protected override void OnUpdaterInsert(Entity ent, ref EntInsertedIntoContainerMessage args) { // TODO: Prediction dump this - if (!TryComp(args.Entity, out SiliconLawProviderComponent? provider)) + if (!TryComp(args.Entity, out SiliconLawBoundComponent? provider)) //ADT custom AI law return; - var lawset = GetLawset(provider.Laws).Laws; + var lawset = GetLaws(args.Entity, provider).Laws; //ADT custom AI law var query = EntityManager.CompRegistryQueryEnumerator(ent.Comp.Components); while (query.MoveNext(out var update)) { SetLaws(lawset, update); } + ///ADT AI Custom law start + UpdateBorgsNTLaws(lawset); + } + private void UpdateBorgsNTLaws(List newLaws) + { + var headRevs = AllEntityQuery(); + while (headRevs.MoveNext(out var uid, out var lawprov, out _)) + { + if (_faction.IsMember(uid, "NanoTrasen") && lawprov.Lawset != null) + lawprov.Lawset.Laws = newLaws; + } + return; } + ///ADT AI Custom law end } [ToolshedCommand, AdminCommand(AdminFlags.Admin)] diff --git a/Resources/Locale/ru-RU/ADT/prototypes/Entities/Objects/Device/Circuitboards/aicustomlaw.ftl b/Resources/Locale/ru-RU/ADT/prototypes/Entities/Objects/Device/Circuitboards/aicustomlaw.ftl new file mode 100644 index 00000000000..7c87389d567 --- /dev/null +++ b/Resources/Locale/ru-RU/ADT/prototypes/Entities/Objects/Device/Circuitboards/aicustomlaw.ftl @@ -0,0 +1,2 @@ +ent-ADTCustomLawCircuitBoard = плата смены законов ИИ + .desc = Модификация обычный платы законов, позволяющая полностью переписать их при помощи мультитула. diff --git a/Resources/Locale/ru-RU/administration/ui/silicon-law-ui.ftl b/Resources/Locale/ru-RU/administration/ui/silicon-law-ui.ftl index 50ae1c879d4..ec0fafcf18a 100644 --- a/Resources/Locale/ru-RU/administration/ui/silicon-law-ui.ftl +++ b/Resources/Locale/ru-RU/administration/ui/silicon-law-ui.ftl @@ -1,5 +1,5 @@ silicon-law-ui-verb = Управление законами -silicon-law-ui-title = Кремниевые законы +silicon-law-ui-title = Законы ИИ silicon-law-ui-new-law = Новый закон silicon-law-ui-save = Сохранить изменения silicon-law-ui-plus-one = +1 diff --git a/Resources/Prototypes/ADT/Entities/Objects/Devices/Circuitboards/aicustomlaw.yml b/Resources/Prototypes/ADT/Entities/Objects/Devices/Circuitboards/aicustomlaw.yml new file mode 100644 index 00000000000..ddd5685ea1c --- /dev/null +++ b/Resources/Prototypes/ADT/Entities/Objects/Devices/Circuitboards/aicustomlaw.yml @@ -0,0 +1,13 @@ +- type: entity + id: ADTCustomLawCircuitBoard + parent: BaseElectronics + name: custom ai law circuit board + description: An electronics board containing a lawset. + components: + - type: Sprite + sprite: Objects/Misc/module.rsi + state: cpuboard_adv + - type: SiliconLawBound + - type: CustomAiLawBoard + - type: SiliconLawProvider + laws: NTDefault \ No newline at end of file From 63b266400e154c50539f49d6569f469b4a3e5cf4 Mon Sep 17 00:00:00 2001 From: RevengenRat <138193222+Ratyyy@users.noreply.github.com> Date: Sun, 8 Sep 2024 23:04:08 +0300 Subject: [PATCH 2/4] craft --- Resources/Prototypes/ADT/Recipes/Lathes/robotics.yml | 12 ++++++++++++ .../Entities/Structures/Machines/lathe.yml | 1 + 2 files changed, 13 insertions(+) diff --git a/Resources/Prototypes/ADT/Recipes/Lathes/robotics.yml b/Resources/Prototypes/ADT/Recipes/Lathes/robotics.yml index 3aa7b5f42da..19b0c1a5030 100644 --- a/Resources/Prototypes/ADT/Recipes/Lathes/robotics.yml +++ b/Resources/Prototypes/ADT/Recipes/Lathes/robotics.yml @@ -113,3 +113,15 @@ Glass: 500 Plastic: 250 Gold: 50 + +- type: latheRecipe + id: ADTCustomLawCircuitBoard + result: ADTCustomLawCircuitBoard + category: Robotics + completetime: 3 + materials: + Steel: 500 + Glass: 500 + Plastic: 250 + Gold: 50 + Plasma: 50 \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index 7bdef979c4c..b0ff82e2a3c 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -510,6 +510,7 @@ - SpaceHeaterMachineCircuitBoard - CutterMachineCircuitboard - StationAnchorCircuitboard + - ADTCustomLawCircuitBoard dynamicRecipes: - ThermomachineFreezerMachineCircuitBoard - HellfireFreezerMachineCircuitBoard From cb58413eb33170d53baa55a08fb48b8eb10dfcb6 Mon Sep 17 00:00:00 2001 From: RevengenRat <138193222+Ratyyy@users.noreply.github.com> Date: Sun, 8 Sep 2024 23:14:10 +0300 Subject: [PATCH 3/4] Update SiliconLawSystem.cs --- .../Silicons/Laws/SiliconLawSystem.cs | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/Content.Server/Silicons/Laws/SiliconLawSystem.cs b/Content.Server/Silicons/Laws/SiliconLawSystem.cs index e91769f12d8..eaac0f8ea6f 100644 --- a/Content.Server/Silicons/Laws/SiliconLawSystem.cs +++ b/Content.Server/Silicons/Laws/SiliconLawSystem.cs @@ -21,35 +21,8 @@ using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Toolshed; -using Content.Server.Antag; -using Content.Server.Communications; -using Content.Server.GameTicking.Rules.Components; -using Content.Server.Nuke; -using Content.Server.NukeOps; -using Content.Server.Popups; -using Content.Server.Roles; -using Content.Server.RoundEnd; -using Content.Server.Shuttles.Events; -using Content.Server.Shuttles.Systems; -using Content.Server.Station.Components; -using Content.Server.Store.Components; -using Content.Server.Store.Systems; -using Content.Shared.GameTicking.Components; -using Content.Shared.Mobs; -using Content.Shared.Mobs.Components; using Content.Shared.NPC.Components; using Content.Shared.NPC.Systems; -using Content.Shared.Nuke; -using Content.Shared.NukeOps; -using Content.Shared.Store; -using Content.Shared.Tag; -using Content.Shared.Zombies; -using Robust.Shared.Map; -using Robust.Shared.Random; -using Robust.Shared.Utility; -using System.Linq; -using Content.Shared.CombatMode.Pacification; -using Content.Shared.Store.Components; namespace Content.Server.Silicons.Laws; From d475d9feee9488cc3cd44125d3630fefd56b3fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schr=C3=B6dinger?= <132720404+Schrodinger71@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:32:08 +0300 Subject: [PATCH 4/4] Update SiliconLawSystem.cs --- Content.Server/Silicons/Laws/SiliconLawSystem.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Content.Server/Silicons/Laws/SiliconLawSystem.cs b/Content.Server/Silicons/Laws/SiliconLawSystem.cs index eaac0f8ea6f..8b10517efa1 100644 --- a/Content.Server/Silicons/Laws/SiliconLawSystem.cs +++ b/Content.Server/Silicons/Laws/SiliconLawSystem.cs @@ -278,6 +278,7 @@ public void SetLaws(List newLaws, EntityUid target) { if (!TryComp(target, out var component)) return; + if (component.Lawset == null) component.Lawset = new SiliconLawset();