Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
using Content.Shared.Body.Part;
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Content.Shared._HL.Silicons.Components;
using Content.Shared.Interaction.Events;
using Content.Server.Popups;

namespace Content.Server._CorvaxNext.Silicons.Borgs;

Expand All @@ -35,6 +38,7 @@ public sealed class AiRemoteControlSystem : SharedAiRemoteControlSystem
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
[Dependency] private readonly PositronicJumpSystem _positronicJumpSystem = default!; //Hardlight: Incorporates positronic jump system into transfer
[Dependency] private readonly TransformSystem _transformSystem = default!; //Used to prevent AI from selecting borgs from list that aren't on same grid
[Dependency] private readonly PopupSystem _popupSystem = default!;

public override void Initialize()
{
Expand All @@ -49,7 +53,26 @@ public override void Initialize()

SubscribeLocalEvent<AiRemoteBrainComponent, EntGotInsertedIntoContainerMessage>(OnBrainInserted);
SubscribeLocalEvent<AiRemoteBrainComponent, EntGotRemovedFromContainerMessage>(OnBrainRemoved);

SubscribeLocalEvent<AIShuntReceiverComponent, UseInHandEvent>(OnShuntRadioUsed); //Hardlight: For setting the AIShuntRadioComponent grid
}

//Hardlight:
/// <summary>
/// Sets the receiver's assigned grid so an AI on that grid can access it.
/// </summary>
/// <param name="ent"></param>
/// <param name="args"></param>
private void OnShuntRadioUsed(Entity<AIShuntReceiverComponent> ent, ref UseInHandEvent args)
{
if (!TryComp<AIShuntReceiverComponent>(ent, out var radioComponent))
return;

radioComponent.AssignedGrid = _transformSystem.GetGrid(args.User);

_popupSystem.PopupEntity("Radio linked to local grid", args.User, args.User);
}
//Hardlight End

private void OnBrainInserted(EntityUid uid, AiRemoteBrainComponent component, EntGotInsertedIntoContainerMessage args)
{
Expand Down Expand Up @@ -204,14 +227,23 @@ private void OnToggleRemoteDevicesScreen(EntityUid uid, StationAiHeldComponent c
var targetEntity = GetEntity(GetNetEntity(queryUid));
var targetGrid = _transformSystem.GetGrid(targetEntity);

if (targetGrid == null || targetGrid != aiGrid)
//Checks to make sure the borg entity has the AIShuntReceiver component
if (!TryComp<BorgChassisComponent>(targetEntity, out var chassis))
continue;

if (!TryComp<AIShuntReceiverComponent>(chassis.BrainContainer.ContainedEntity, out var radioComponent))
continue;

//Checks to make sure AIShuntReceiver is set to proper grid
if (radioComponent.AssignedGrid == null || radioComponent?.AssignedGrid != aiGrid)
continue;

//Only lists borgs that pass the valid candidate check
//TODO: Consider potentially moving grid check into this function
if (!_positronicJumpSystem.IsTargetValidControlCandidate(uid, targetEntity))
continue;
//Hardlight end

var data = new RemoteDevicesData
{
NetEntityUid = GetNetEntity(queryUid),
Expand Down
49 changes: 42 additions & 7 deletions Content.Server/_CorvaxNext/Silicons/Borgs/PositronicJumpSystem.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
using System.Linq;
using Content.Server._CorvaxNext.Silicons.Borgs.Components;
using Content.Server._Mono.SpaceArtillery.Components;
using Content.Server._NF.Roles.Systems; // VRS: move JobTrackingComponent across shunt (HL #1354)
using Content.Server.Mech.Systems;
using Content.Server.Silicons.Borgs;
using Content.Server.Silicons.Laws;
using Content.Server.SurveillanceCamera;
using Content.Server._CorvaxNext.Silicons.Borgs.Components;
using Content.Server._Mono.SpaceArtillery.Components;
using Content.Server._NF.Roles.Systems; // VRS: move JobTrackingComponent across shunt (HL #1354)
using Content.Shared._CorvaxNext.Silicons.Borgs;
using Content.Shared._HL.Silicons.Components;
using Content.Shared._NF.Roles.Components; // VRS: move JobTrackingComponent across shunt (HL #1354)
using Content.Shared.Mech.Components;
using Content.Shared.Actions;
using Content.Shared.Mech.Components;
using Content.Shared.Mind;
using Content.Shared.PAI;
using Content.Shared.Popups;
using Content.Shared._CorvaxNext.Silicons.Borgs;
using Content.Shared.Roles.Jobs;
using Content.Shared.Silicons.Borgs.Components;
using Content.Shared.Silicons.Laws.Components;
using Content.Shared.Silicons.StationAi;
using Content.Shared.Turrets;
using Content.Shared.Verbs;
using Robust.Shared.GameStates;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using System.Linq;

namespace Content.Server._CorvaxNext.Silicons.Borgs;

Expand All @@ -33,6 +36,7 @@ public sealed class PositronicJumpSystem : EntitySystem
[Dependency] private readonly MechSystem _mech = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly JobTrackingSystem _jobTracking = default!; // VRS: HL #1354
[Dependency] private readonly TransformSystem _transformSystem = default!;

private const string ReturnToAiAction = "ActionBackToAi";

Expand Down Expand Up @@ -118,6 +122,10 @@ private void OnBorgChassisGetVerbs(EntityUid uid, BorgChassisComponent component
if (_mind.TryGetMind(uid, out _, out _))
return;

//Hardlight: If the user is an AI, then make sure target isn't invalid borg
if (HasComp<StationAiHeldComponent>(args.User) && !AITargetingValidBorg(args.User, uid))
return;
//Hardlight End
var user = args.User;
var target = uid;

Expand Down Expand Up @@ -329,6 +337,11 @@ public bool TryTakeControl(EntityUid user, EntityUid target)
if (mind.OwnedEntity == target)
return false;

//Hardlight: If user is AI make sure they're not taking over an invalid borg
if (HasComp<StationAiHeldComponent>(user) && !AITargetingValidBorg(user, target))
return false;
//Hardlight end

if (mind.OwnedEntity != null)
TransferReturnState(mind.OwnedEntity.Value, target);

Expand Down Expand Up @@ -362,6 +375,28 @@ public bool IsTargetValidControlCandidate(EntityUid user, EntityUid target)
return true;
}

//Hardlight:
/// <summary>
/// Checks if the target is a borg and if so, make sure it has the proper receiver
/// installed to restrict AI takeovers.
/// </summary>
/// <param name="user"></param>
/// <param name="target"></param>
/// <returns></returns>
public bool AITargetingValidBorg(EntityUid user, EntityUid target)
{
if (!TryComp<BorgChassisComponent>(target, out var chassis))
return true;

if (!TryComp<AIShuntReceiverComponent>(chassis.BrainContainer.ContainedEntity, out var radioComponent))
return false;

if (radioComponent.AssignedGrid == null || radioComponent?.AssignedGrid != _transformSystem.GetGrid(user))
return false;

return true;
}
//Hardlight End
public bool TryReturnControl(EntityUid target)
{
if (TryComp<RemoteMechPilotComponent>(target, out var remoteMechPilot))
Expand Down
15 changes: 15 additions & 0 deletions Content.Shared/_HL/Silicons/Components/AIShuntReceiverComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Robust.Shared.GameStates;
using System;
using System.Collections.Generic;
using System.Text;

namespace Content.Shared._HL.Silicons.Components
{
[RegisterComponent, NetworkedComponent]
public sealed partial class AIShuntReceiverComponent : Component
{
[ViewVariables]
[DataField]
public EntityUid? AssignedGrid = null;
}
}
1 change: 1 addition & 0 deletions Resources/Prototypes/Recipes/Lathes/Packs/robotics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
recipes:
- MMI
- PositronicBrain
- AIShuntReceiver # Hardlight
- SciFlash
- CyborgEndoskeleton
- Quadborgendoskeleton
Expand Down
14 changes: 14 additions & 0 deletions Resources/Prototypes/Recipes/Lathes/robotics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,20 @@
Silver: 100
Plasma: 1000

# Hardlight
- type: latheRecipe
parent: BaseRoboticsRecipe
id: AIShuntReceiver
result: AIShuntReceiver
completetime: 3
materials:
Steel: 500
Plastic: 500
Gold: 100
Silver: 100
Plasma: 1000
# Hardlight End

# Modules

- type: latheRecipe
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
- type: entity
parent: [ BaseItem, BaseSiliconBrainLanguages ]
id: AIShuntReceiver
name: AI Shunt Receiver
description: A long range receiver for an AI to shunt into. Works off-grid at any distance. Must be linked to AI's grid first.
components:
- type: Sprite
sprite: _HL/Objects/Specific/Robotics/mmi.rsi
layers:
- state: aishuntreceiver
- state: aishuntreceiver_overlay
- type: Input
context: human
- type: Organ
slotId: brain
- type: Brain
- type: BlockMovement
- type: Examiner
- type: BorgBrain
- type: IntrinsicRadioReceiver
- type: IntrinsicRadioTransmitter
channels:
- Binary
- type: ActiveRadio
channels:
- Binary
- Common
- type: NameIdentifier
group: PositronicBrain
- type: DoAfter
- type: Actions
- type: TypingIndicator
proto: robot
- type: Speech
speechSounds: Pai
- type: Alerts
- type: MobState
allowedStates:
- Alive
- Dead
- type: Appearance
- type: Tag
tags:
- CannotSuicide
- type: GuideHelp
guides:
- Cyborgs
- Robotics
- type: ChangeVoiceInContainer
whitelist:
components:
- SecretStash
- type: RetroMonitorView # Mono - #3902
- type: AIShuntReceiver
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions Resources/Textures/_HL/Objects/Specific/Robotics/mmi.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "PAI overlay sprite taken from tgstation at commit https://github.com/tgstation/tgstation/commit/9ddb8cf084e292571d4e9c79745db25befbd82fe and edited by Typheus",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "aishuntreceiver"
},
{
"name": "aishuntreceiver_overlay",
"delays": [
[
0.8,
0.8
]
]
}
]
}
Loading