Skip to content

Commit

Permalink
Merge branch 'auto_cl_update_v2' of https://github.com/themanyfacedde…
Browse files Browse the repository at this point in the history
…mon/space_station_ADT into auto_cl_update_v2
  • Loading branch information
themanyfaceddemon committed Oct 27, 2024
2 parents c6d1645 + 5d19c6a commit b7d50e8
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Content.Server/ADT/CustomAILaw/CustomAiLawBoardComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Content.Server.ADT.CustomAiLawBoard;

[RegisterComponent]
public sealed partial class CustomAiLawBoardComponent : Component
{

}
41 changes: 41 additions & 0 deletions Content.Server/ADT/CustomAILaw/CustomAiLawBoardSystem.cs
Original file line number Diff line number Diff line change
@@ -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<CustomAiLawBoardComponent, InteractUsingEvent>(OnInteractUsing);
}
private void OnInteractUsing(EntityUid uid, CustomAiLawBoardComponent comp, InteractUsingEvent args)
{
if (args.Handled)
return;

if (!_toolSystem.HasQuality(args.Used, SharedToolSystem.PulseQuality))
return;

if (!TryComp<SiliconLawBoundComponent>(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);
}
}
8 changes: 4 additions & 4 deletions Content.Server/Silicons/Laws/SiliconLawEui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
20 changes: 18 additions & 2 deletions Content.Server/Silicons/Laws/SiliconLawSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Toolshed;
using Content.Shared.NPC.Components;
using Content.Shared.NPC.Systems;

namespace Content.Server.Silicons.Laws;

Expand All @@ -34,6 +36,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!;

/// <inheritdoc/>
public override void Initialize()
Expand Down Expand Up @@ -286,17 +289,30 @@ public void SetLaws(List<SiliconLaw> newLaws, EntityUid target)
protected override void OnUpdaterInsert(Entity<SiliconLawUpdaterComponent> 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<SiliconLaw> newLaws)
{
var headRevs = AllEntityQuery<SiliconLawProviderComponent, NpcFactionMemberComponent>();
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)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-ADTCustomLawCircuitBoard = плата смены законов ИИ
.desc = Модификация обычный платы законов, позволяющая полностью переписать их при помощи мультитула.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions Resources/Prototypes/ADT/Recipes/Lathes/robotics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@
- SpaceHeaterMachineCircuitBoard
- CutterMachineCircuitboard
- StationAnchorCircuitboard
- ADTCustomLawCircuitBoard # ADT tweak
- SalvageMagnetMachineCircuitboard
dynamicRecipes:
- ThermomachineFreezerMachineCircuitBoard
Expand Down

0 comments on commit b7d50e8

Please sign in to comment.