Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
8 changes: 6 additions & 2 deletions Content.Shared/Silicons/Borgs/SharedBorgSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ protected virtual void OnInserted(Entity<BorgChassisComponent> chassis, ref EntI
EnsureComp<StationAIShuntComponent>(chassis, out var borgShunt)
)
{
shuntable.Inhabited = chassis;
shuntable.Inhabited = chassis; // Starlight
Comment thread
Proximitron marked this conversation as resolved.
Outdated
shuntable.LastShunt = chassis; // Starlight
Dirty(shunt.Return.Value, shuntable); // Starlight
borgShunt.Return = shunt.Return;
borgShunt.ReturnAction = _actions.AddAction(chassis, shuntable.UnshuntAction);
}
Expand Down Expand Up @@ -254,7 +256,9 @@ protected virtual void OnRemoved(Entity<BorgChassisComponent> chassis, ref EntRe
TryComp<StationAIShuntableComponent>(shunt.Return, out var shuntable) &&
TryComp<StationAIShuntComponent>(chassis, out var borgShunt))
{
shuntable.Inhabited = args.Entity;
shuntable.Inhabited = args.Entity; // Starlight
Comment thread
Proximitron marked this conversation as resolved.
Outdated
shuntable.LastShunt = args.Entity; // Starlight
Dirty(shunt.Return.Value, shuntable); // Starlight
if (TryComp<ActionComponent>(borgShunt.ReturnAction, out var action))
_actions.RemoveAction((borgShunt.ReturnAction.Value, action)); //delete the action as we leave the body
borgShunt.Return = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Content.Shared.Actions;

namespace Content.Shared._Starlight.Silicons.Borgs;

public sealed partial class StationAIShuntSystem
{
private void InitializeReconnect()
{
SubscribeLocalEvent<StationAIShuntableComponent, AIReconnectShuntActionEvent>(OnAttemptReconnect);

Check warning on line 9 in Content.Shared/_Starlight/Silicons/Borgs/StationAIShuntSystem.Reconnect.cs

View workflow job for this annotation

GitHub Actions / build

[C# diagnostics] reported by reviewdog 🐶 Use expression body for method Raw Output: {"level":"warning","locations":[{"physicalLocation":{"artifactLocation":{"uri":"file:///home/runner/work/space-station-14/space-station-14/Content.Shared/_Starlight/Silicons/Borgs/StationAIShuntSystem.Reconnect.cs"},"region":{"endColumn":107,"endLine":9,"startColumn":9,"startLine":9}}}],"message":{"text":"Use expression body for method"},"properties":{},"relatedLocations":[{"physicalLocation":{"artifactLocation":{"uri":"file:///home/runner/work/space-station-14/space-station-14/Content.Shared/_Starlight/Silicons/Borgs/StationAIShuntSystem.Reconnect.cs"},"region":{"endColumn":6,"endLine":10,"startColumn":5,"startLine":7}}}],"ruleId":"IDE0022","ruleIndex":517}
}

private void OnAttemptReconnect(EntityUid uid, StationAIShuntableComponent shuntable, AIReconnectShuntActionEvent ev)
{
if (ev.Handled || shuntable.Inhabited.HasValue || shuntable.LastShunt is not { } lastShunt || Deleted(lastShunt))
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return;

var shuntEv = new AIShuntActionEvent
{
Target = lastShunt,
Performer = uid,
IgnoreCameraView = true
};
RaiseLocalEvent(uid, shuntEv);
ev.Handled = shuntEv.Handled;
}
}

public sealed partial class AIReconnectShuntActionEvent : Content.Shared.Actions.InstantActionEvent
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public override void Initialize()

SubscribeLocalEvent<StationAIShuntThroughComponent, GetVerbsEvent<AlternativeVerb>>(GetAltVerbs);
SubscribeLocalEvent<StationAIShuntThroughComponent, FindShuntTargetEvent>(OnFindShuntTarget);
InitializeReconnect();
}

#region Actions
Expand All @@ -50,7 +51,7 @@ private void OnAttemptShunt(EntityUid uid, StationAIShuntableComponent shuntable
if (ev.Handled)
return;
var target = ev.Target;
if (_vision.IsOutsideCameraViewCached(target))
if (!ev.IgnoreCameraView && _vision.IsOutsideCameraViewCached(target))
return;

// If target has ShuntThrough component, search for a valid target in containers
Expand Down Expand Up @@ -107,6 +108,8 @@ private void OnAttemptShunt(EntityUid uid, StationAIShuntableComponent shuntable
_mindSystem.TransferTo(mindId, target);
shunt.ReturnAction = _actionSystem.AddAction(target, shuntable.UnshuntAction.Id);
shuntable.Inhabited = target;
shuntable.LastShunt = target;
Dirty(uid, shuntable);

if (TryComp<SiliconLawProviderComponent>(uid, out var coreLaws))
{
Expand Down Expand Up @@ -317,6 +320,7 @@ private void OnFindShuntTarget(EntityUid uid, StationAIShuntThroughComponent com

public sealed partial class AIShuntActionEvent : EntityTargetActionEvent
{
public bool IgnoreCameraView;
}

public sealed partial class AIUnShuntActionEvent : InstantActionEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;

namespace Content.Shared._Starlight.Silicons.Borgs;

public sealed partial class StationAIShuntableComponent
{
/// <summary>
/// The last shunt target used by this AI, if it still exists.
/// </summary>
[ViewVariables]
[DataField, AutoNetworkedField]
public EntityUid? LastShunt { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Content.Shared._Starlight.Silicons.Borgs;
/// <summary>
/// This comp is added to station AI's invisible posibrain to handle shunting logics.
/// </summary>
[RegisterComponent, NetworkedComponent]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class StationAIShuntableComponent : Component
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/_Starlight/station-ai/verbs.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ai-shunt-into = Enter Chassis
ai-shunt-out-of = Exit Chassis
ai-shunt-reconnect = Reconnect Chassis
Comment thread
coderabbitai[bot] marked this conversation as resolved.
5 changes: 2 additions & 3 deletions Resources/Prototypes/Entities/Mobs/Player/silicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- ActionSurvCameraLights
- ActionAIViewLaws
- ActionAIShunt # Starlight AI Shunt ability
- ActionAIReconnectShunt # Starlight AI Shunt reconnect ability
Comment thread
coderabbitai[bot] marked this conversation as resolved.
- ActionAIWarp # Starlight
- type: UserInterface
interfaces:
Expand Down Expand Up @@ -85,9 +86,7 @@
- sprite: Mobs/Silicon/station_ai.rsi
state: default
- type: ShowJobIcons
#region Starlight
- type: StationAIShuntable
#endregion Starlight
- type: StationAIShuntable # Starlight
- type: DamagedSiliconAccent
startPowerCorruptionAtCharIdx: 4
maxPowerCorruptionAtCharIdx: 20
Expand Down
14 changes: 14 additions & 0 deletions Resources/Prototypes/_Starlight/station_ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,27 @@
- type: InstantAction
event: !type:AIUnShuntActionEvent

- type: entity
parent: BaseMentalAction
id: ActionAIReconnectShunt
name: Reconnect Shunt
description: Reconnect to the last chassis or interface you shunted into.
components:
- type: Action
icon:
{ sprite: _Starlight/Interface/Actions/actions_shunt.rsi, state: icon }
itemIconStyle: BigAction
- type: InstantAction
event: !type:AIReconnectShuntActionEvent

- type: entity
parent: BaseAction
id: ActionAIWarp
name: Warp
description: Open a list of crew and locations to warp to.
components:
- type: Action
priority: 3
itemIconStyle: BigAction
icon:
sprite: Interface/Actions/actions_ai.rsi
Expand Down
Loading