Skip to content

Commit

Permalink
Done, needs testing
Browse files Browse the repository at this point in the history
  • Loading branch information
FireNameFN committed Nov 13, 2024
1 parent c396a36 commit 79035cb
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ protected override void Open()
_window = this.CreateWindow<RoboticsConsoleWindow>();
_window.SetEntity(Owner);

// Corvax-Next-MutableLaws-Start
_window.OnChangeLawsPressed += address =>
{
SendMessage(new RoboticsConsoleChangeLawsMessage(address));
};
// Corvax-Next-MutableLaws-End
_window.OnDisablePressed += address =>
{
SendMessage(new RoboticsConsoleDisableMessage(address));
Expand Down
5 changes: 4 additions & 1 deletion Content.Client/Robotics/UI/RoboticsConsoleWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
</BoxContainer>
<controls:StripeBack>
<BoxContainer Name="DangerZone" Margin="5" Orientation="Horizontal" HorizontalExpand="True" HorizontalAlignment="Center" Visible="False">
<Button Name="DisableButton" Text="{Loc 'robotics-console-disable'}" StyleClasses="OpenRight"/>
<!-- Corvax-Next-MutableLaws-Start -->
<Button Name="ChangeLawsButton" Text="{Loc 'robotics-console-change-laws'}" StyleClasses="OpenRight"/>
<Button Name="DisableButton" Text="{Loc 'robotics-console-disable'}" StyleClasses="OpenBoth"/>
<!-- Corvax-Next-MutableLaws-End -->
<Button Name="DestroyButton" Text="{Loc 'robotics-console-destroy'}" StyleClasses="OpenLeft"/>
</BoxContainer>
<Label Name="LockedMessage" Text="{Loc 'robotics-console-locked-message'}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
Expand Down
7 changes: 7 additions & 0 deletions Content.Client/Robotics/UI/RoboticsConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public sealed partial class RoboticsConsoleWindow : FancyWindow
private readonly LockSystem _lock;
private readonly SpriteSystem _sprite;

public Action<string>? OnChangeLawsPressed; // Corvax-Next-MutableLaws
public Action<string>? OnDisablePressed;
public Action<string>? OnDestroyPressed;

Expand Down Expand Up @@ -51,6 +52,12 @@ public RoboticsConsoleWindow()
};

// these won't throw since buttons are only visible if a borg is selected
// Corvax-Next-MutableLaws-Start
ChangeLawsButton.OnPressed += _ =>
{
OnChangeLawsPressed?.Invoke(_selected!);
};
// Corvax-Next-MutableLaws-End
DisableButton.OnPressed += _ =>
{
OnDisablePressed?.Invoke(_selected!);
Expand Down
35 changes: 35 additions & 0 deletions Content.Server/Robotics/Systems/RoboticsConsoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
using Robust.Server.GameObjects;
using Robust.Shared.Timing;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Silicons.Laws.Components;
using Content.Server.Silicons.Laws;

namespace Content.Server.Research.Systems;

Expand All @@ -26,6 +29,8 @@ public sealed class RoboticsConsoleSystem : SharedRoboticsConsoleSystem
[Dependency] private readonly LockSystem _lock = default!;
[Dependency] private readonly RadioSystem _radio = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly ItemSlotsSystem _slots = default!;
[Dependency] private readonly SiliconLawSystem _law = default!;

// almost never timing out more than 1 per tick so initialize with that capacity
private List<string> _removing = new(1);
Expand All @@ -38,6 +43,7 @@ public override void Initialize()
Subs.BuiEvents<RoboticsConsoleComponent>(RoboticsConsoleUiKey.Key, subs =>
{
subs.Event<BoundUIOpenedEvent>(OnOpened);
subs.Event<RoboticsConsoleChangeLawsMessage>(OnChangeLaws); // Corvax-Next-MutableLaws
subs.Event<RoboticsConsoleDisableMessage>(OnDisable);
subs.Event<RoboticsConsoleDestroyMessage>(OnDestroy);
// TODO: camera stuff
Expand Down Expand Up @@ -94,6 +100,35 @@ private void OnOpened(Entity<RoboticsConsoleComponent> ent, ref BoundUIOpenedEve
UpdateUserInterface(ent);
}

// Corvax-Next-MutableLaws-Start
private void OnChangeLaws(Entity<RoboticsConsoleComponent> ent, ref RoboticsConsoleChangeLawsMessage args)
{
if (_lock.IsLocked(ent.Owner))
return;

if (!ent.Comp.Cyborgs.TryGetValue(args.Address, out var data))
return;

if (!_slots.TryGetSlot(ent, "circuit_holder", out var slot) || !slot.HasItem)
return;

if (!TryComp<SiliconLawProviderComponent>(slot.Item, out var law))
return;

var payload = new NetworkPayload()
{
[DeviceNetworkConstants.Command] = RoboticsConsoleConstants.NET_CHANGE_LAWS_COMMAND,
[RoboticsConsoleConstants.NET_LAWS] = _law.GetLawset(law.Laws).Laws,
};

_deviceNetwork.QueuePacket(ent, args.Address, payload);

var message = Loc.GetString(ent.Comp.ChangeLawsMessage, ("name", data.Name));
_radio.SendRadioMessage(ent, message, ent.Comp.RadioChannel, ent);
_adminLogger.Add(LogType.Action, LogImpact.High, $"{ToPrettyString(args.Actor):user} changed laws of borg {data.Name} with address {args.Address}");
}
// Corvax-Next-MutableLaws-End

private void OnDisable(Entity<RoboticsConsoleComponent> ent, ref RoboticsConsoleDisableMessage args)
{
if (_lock.IsLocked(ent.Owner))
Expand Down
24 changes: 23 additions & 1 deletion Content.Server/Silicons/Borgs/BorgSystem.Transponder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
using Content.Server.DeviceNetwork.Components;
using Content.Server.DeviceNetwork.Systems;
using Content.Server.Explosion.Components;
using Content.Shared.Silicons.Laws;
using Content.Server.Silicons.Laws;
using Robust.Shared.Audio;

namespace Content.Server.Silicons.Borgs;

/// <inheritdoc/>
public sealed partial class BorgSystem
{
[Dependency] private readonly SiliconLawSystem _law = default!;

private void InitializeTransponder()
{
SubscribeLocalEvent<BorgTransponderComponent, DeviceNetworkPacketEvent>(OnPacketReceived);
Expand Down Expand Up @@ -83,12 +88,29 @@ private void OnPacketReceived(Entity<BorgTransponderComponent> ent, ref DeviceNe
if (!payload.TryGetValue(DeviceNetworkConstants.Command, out string? command))
return;

if (command == RoboticsConsoleConstants.NET_DISABLE_COMMAND)
// Corvax-Next-MutableLaws-Start
if (command == RoboticsConsoleConstants.NET_CHANGE_LAWS_COMMAND)
{
if (payload.TryGetValue(RoboticsConsoleConstants.NET_LAWS, out List<SiliconLaw>? laws))
ChangeLaws(ent, laws);
}
// Corvax-Next-MutableLaws-End
else if (command == RoboticsConsoleConstants.NET_DISABLE_COMMAND)
Disable(ent);
else if (command == RoboticsConsoleConstants.NET_DESTROY_COMMAND)
Destroy(ent);
}

// Corvax-Next-MutableLaws-Start
private void ChangeLaws(EntityUid ent, List<SiliconLaw> laws)
{
if (CheckEmagged(ent, "destroyed"))
return;

_law.SetLaws(laws, ent, new SoundPathSpecifier("/Audio/Misc/cryo_warning.ogg"));
}
// Corvax-Next-MutableLaws-End

private void Disable(Entity<BorgTransponderComponent, BorgChassisComponent?> ent)
{
if (!Resolve(ent, ref ent.Comp2) || ent.Comp2.BrainEntity == null || ent.Comp1.NextDisable != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public sealed partial class RoboticsConsoleComponent : Component
[DataField]
public ProtoId<RadioChannelPrototype> RadioChannel = "Science";

// Corvax-Next-MutableLaws-Start
[DataField]
public LocId ChangeLawsMessage = "robotics-console-cyborg-change-laws";
// Corvax-Next-MutableLaws-End

/// <summary>
/// Radio message sent when destroying a borg.
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions Content.Shared/Robotics/RoboticsConsoleUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ public RoboticsConsoleState(Dictionary<string, CyborgControlData> cyborgs)
}
}

// Corvax-Next-MutableLaws-Start
[Serializable, NetSerializable]
public sealed class RoboticsConsoleChangeLawsMessage : BoundUserInterfaceMessage
{
public readonly string Address;

public RoboticsConsoleChangeLawsMessage(string address)
{
Address = address;
}
}
// Corvax-Next-MutableLaws-End

/// <summary>
/// Message to disable the selected cyborg.
/// </summary>
Expand Down Expand Up @@ -129,6 +142,9 @@ public static class RoboticsConsoleConstants
public const string NET_CYBORG_DATA = "cyborg-data";

// sent by robotics console to cyborgs on Cyborg Control frequency
public const string NET_CHANGE_LAWS_COMMAND = "cyborg-change-laws"; // Corvax-Next-MutableLaws
public const string NET_DISABLE_COMMAND = "cyborg-disable";
public const string NET_DESTROY_COMMAND = "cyborg-destroy";

public const string NET_LAWS = "cyborg-laws"; // Corvax-Next-MutableLaws
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
research-technology-advanced-robotics = Продвинутая робототехника
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ robotics-console-locked-message = Управление заблокирован
robotics-console-disable = Отключить
robotics-console-destroy = Уничтожить
robotics-console-cyborg-destroying = Запущен процесс дистанционного уничтожения { $name }!
# Corvax-Next-MutableLaws-Start
robotics-console-change-laws = Изменить законы
robotics-console-cyborg-change-laws = Законы { $name } изменены!
# Corvax-Next-MutableLaws-End
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,21 @@
access: [["ResearchDirector"]]
- type: Lock
unlockOnClick: false
# Corvax-Next-MutableLaws-Start
- type: ItemSlots
slots:
circuit_holder:
name: circuit-holder
whitelist:
requireAll: true
components:
- SiliconLawProvider
- Item
- type: ContainerContainer
containers:
circuit_holder: !type:ContainerSlot
board: !type:Container
# Corvax-Next-MutableLaws-End

- type: entity
id: StationAiUploadComputer
Expand Down
13 changes: 13 additions & 0 deletions Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,19 @@
- ReagentGrinderIndustrialMachineCircuitboard
- JukeboxCircuitBoard
- SalvageExpeditionsComputerCircuitboard # Corvax-Cringe
# Corvax-Next-MutableLaws-Start
- AsimovCircuitBoard
- CorporateCircuitBoard
- NTDefaultCircuitBoard
- CommandmentCircuitBoard
- PaladinCircuitBoard
- LiveLetLiveCircuitBoard
- StationEfficiencyCircuitBoard
- RobocopCircuitBoard
- DungeonMasterCircuitBoard
- ArtistCircuitBoard
- NutimovCircuitBoard
# Corvax-Next-MutableLaws-End
- type: EmagLatheRecipes
emagDynamicRecipes:
- ShuttleGunDusterCircuitboard
Expand Down
24 changes: 24 additions & 0 deletions Resources/Prototypes/Research/experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,30 @@
- WeaponParticleDecelerator
- HoloprojectorField

# Corvax-Next-MutableLaws-Start
- type: technology
id: AdvancedRobotics
name: research-technology-advanced-robotics
icon:
sprite: Mobs/Silicon/station_ai.rsi
state: ai
discipline: Experimental
tier: 2
cost: 7500
recipeUnlocks:
- AsimovCircuitBoard
- CorporateCircuitBoard
- NTDefaultCircuitBoard
- CommandmentCircuitBoard
- PaladinCircuitBoard
- LiveLetLiveCircuitBoard
- StationEfficiencyCircuitBoard
- RobocopCircuitBoard
- DungeonMasterCircuitBoard
- ArtistCircuitBoard
- NutimovCircuitBoard
# Corvax-Next-MutableLaws-End

# Tier 3

- type: technology
Expand Down
54 changes: 54 additions & 0 deletions Resources/Prototypes/_CorvaxNext/Recipes/Lathes/circuit_boards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
- type: latheRecipe
parent: BaseCircuitboardRecipe
id: AsimovCircuitBoard
result: AsimovCircuitBoard

- type: latheRecipe
parent: BaseCircuitboardRecipe
id: CorporateCircuitBoard
result: CorporateCircuitBoard

- type: latheRecipe
parent: BaseCircuitboardRecipe
id: NTDefaultCircuitBoard
result: NTDefaultCircuitBoard

- type: latheRecipe
parent: BaseCircuitboardRecipe
id: CommandmentCircuitBoard
result: CommandmentCircuitBoard

- type: latheRecipe
parent: BaseCircuitboardRecipe
id: PaladinCircuitBoard
result: PaladinCircuitBoard

- type: latheRecipe
parent: BaseCircuitboardRecipe
id: LiveLetLiveCircuitBoard
result: LiveLetLiveCircuitBoard

- type: latheRecipe
parent: BaseCircuitboardRecipe
id: StationEfficiencyCircuitBoard
result: StationEfficiencyCircuitBoard

- type: latheRecipe
parent: BaseCircuitboardRecipe
id: RobocopCircuitBoard
result: RobocopCircuitBoard

- type: latheRecipe
parent: BaseCircuitboardRecipe
id: DungeonMasterCircuitBoard
result: DungeonMasterCircuitBoard

- type: latheRecipe
parent: BaseCircuitboardRecipe
id: ArtistCircuitBoard
result: ArtistCircuitBoard

- type: latheRecipe
parent: BaseCircuitboardRecipe
id: NutimovCircuitBoard
result: NutimovCircuitBoard

0 comments on commit 79035cb

Please sign in to comment.