Cargo telepad machine linking (#7756)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Content.Server.Access.Systems;
|
using Content.Server.Access.Systems;
|
||||||
using Content.Server.Cargo.Components;
|
using Content.Server.Cargo.Components;
|
||||||
|
using Content.Server.MachineLinking.Components;
|
||||||
|
using Content.Server.MachineLinking.Events;
|
||||||
|
using Content.Server.MachineLinking.System;
|
||||||
using Content.Shared.Access.Components;
|
using Content.Shared.Access.Components;
|
||||||
using Content.Shared.Access.Systems;
|
using Content.Shared.Access.Systems;
|
||||||
using Content.Shared.Cargo;
|
using Content.Shared.Cargo;
|
||||||
using Content.Shared.GameTicking;
|
using Content.Shared.GameTicking;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
|
|
||||||
namespace Content.Server.Cargo
|
namespace Content.Server.Cargo
|
||||||
{
|
{
|
||||||
@@ -35,7 +35,7 @@ namespace Content.Server.Cargo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to assign IDs to bank accounts. Incremental counter.
|
/// Used to assign IDs to bank accounts. Incremental counter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int _accountIndex = 0;
|
private int _accountIndex;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enumeration of all bank accounts.
|
/// Enumeration of all bank accounts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -49,12 +49,18 @@ namespace Content.Server.Cargo
|
|||||||
|
|
||||||
[Dependency] private readonly IdCardSystem _idCardSystem = default!;
|
[Dependency] private readonly IdCardSystem _idCardSystem = default!;
|
||||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||||
|
[Dependency] private readonly SignalLinkerSystem _linker = default!;
|
||||||
|
|
||||||
private void InitializeConsole()
|
private void InitializeConsole()
|
||||||
{
|
{
|
||||||
|
SubscribeLocalEvent<CargoConsoleComponent, ComponentInit>(OnInit);
|
||||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
private void OnInit(EntityUid uid, CargoConsoleComponent console, ComponentInit args)
|
||||||
|
{
|
||||||
|
_linker.EnsureTransmitterPorts(uid, console.SenderPort);
|
||||||
|
}
|
||||||
|
|
||||||
private void Reset(RoundRestartCleanupEvent ev)
|
private void Reset(RoundRestartCleanupEvent ev)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ using Content.Server.Cargo.Components;
|
|||||||
using Content.Server.Labels.Components;
|
using Content.Server.Labels.Components;
|
||||||
using Content.Server.Paper;
|
using Content.Server.Paper;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.MachineLinking.Components;
|
||||||
|
using Content.Server.MachineLinking.Events;
|
||||||
using Content.Shared.Cargo;
|
using Content.Shared.Cargo;
|
||||||
|
using Content.Shared.Cargo.Components;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
@@ -16,6 +19,7 @@ public sealed partial class CargoSystem
|
|||||||
|
|
||||||
private void InitializeTelepad()
|
private void InitializeTelepad()
|
||||||
{
|
{
|
||||||
|
SubscribeLocalEvent<CargoTelepadComponent, ComponentInit>(OnInit);
|
||||||
SubscribeLocalEvent<CargoTelepadComponent, PowerChangedEvent>(OnTelepadPowerChange);
|
SubscribeLocalEvent<CargoTelepadComponent, PowerChangedEvent>(OnTelepadPowerChange);
|
||||||
// Shouldn't need re-anchored event
|
// Shouldn't need re-anchored event
|
||||||
SubscribeLocalEvent<CargoTelepadComponent, AnchorStateChangedEvent>(OnTelepadAnchorChange);
|
SubscribeLocalEvent<CargoTelepadComponent, AnchorStateChangedEvent>(OnTelepadAnchorChange);
|
||||||
@@ -57,6 +61,11 @@ public sealed partial class CargoSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnInit(EntityUid uid, CargoTelepadComponent telepad, ComponentInit args)
|
||||||
|
{
|
||||||
|
_linker.EnsureReceiverPorts(uid, telepad.ReceiverPort);
|
||||||
|
}
|
||||||
|
|
||||||
private void SetEnabled(CargoTelepadComponent component, ApcPowerReceiverComponent? receiver = null,
|
private void SetEnabled(CargoTelepadComponent component, ApcPowerReceiverComponent? receiver = null,
|
||||||
TransformComponent? xform = null)
|
TransformComponent? xform = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,27 +1,21 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Content.Server.Coordinates.Helpers;
|
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Server.UserInterface;
|
using Content.Server.UserInterface;
|
||||||
using Content.Shared.Cargo;
|
using Content.Shared.Cargo;
|
||||||
using Content.Shared.Cargo.Components;
|
using Content.Shared.Cargo.Components;
|
||||||
using Content.Shared.Sound;
|
using Content.Shared.Sound;
|
||||||
|
using Content.Server.MachineLinking.Components;
|
||||||
|
using Content.Shared.MachineLinking;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.Cargo.Components
|
namespace Content.Server.Cargo.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed class CargoConsoleComponent : SharedCargoConsoleComponent
|
public sealed class CargoConsoleComponent : SharedCargoConsoleComponent
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
|
||||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||||
|
|
||||||
private CargoBankAccount? _bankAccount;
|
private CargoBankAccount? _bankAccount;
|
||||||
@@ -64,6 +58,9 @@ namespace Content.Server.Cargo.Components
|
|||||||
|
|
||||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(CargoConsoleUiKey.Key);
|
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(CargoConsoleUiKey.Key);
|
||||||
|
|
||||||
|
[DataField("senderPort", customTypeSerializer: typeof(PrototypeIdSerializer<TransmitterPortPrototype>))]
|
||||||
|
public string SenderPort = "OrderSender";
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -160,23 +157,18 @@ namespace Content.Server.Cargo.Components
|
|||||||
//orders.Database.ClearOrderCapacity();
|
//orders.Database.ClearOrderCapacity();
|
||||||
|
|
||||||
// TODO replace with shuttle code
|
// TODO replace with shuttle code
|
||||||
// TEMPORARY loop for spawning stuff on telepad (looks for a telepad adjacent to the console)
|
|
||||||
EntityUid? cargoTelepad = null;
|
EntityUid? cargoTelepad = null;
|
||||||
var indices = _entMan.GetComponent<TransformComponent>(Owner).Coordinates.ToVector2i(_entMan, _mapManager);
|
|
||||||
var offsets = new Vector2i[] { new Vector2i(0, 1), new Vector2i(1, 1), new Vector2i(1, 0), new Vector2i(1, -1),
|
|
||||||
new Vector2i(0, -1), new Vector2i(-1, -1), new Vector2i(-1, 0), new Vector2i(-1, 1), };
|
|
||||||
|
|
||||||
var lookup = EntitySystem.Get<EntityLookupSystem>();
|
if (_entMan.TryGetComponent<SignalTransmitterComponent>(Owner, out var transmitter) &&
|
||||||
var gridId = _entMan.GetComponent<TransformComponent>(Owner).GridID;
|
transmitter.Outputs.TryGetValue(SenderPort, out var telepad) &&
|
||||||
|
telepad.Count > 0)
|
||||||
// TODO: Should use anchoring.
|
|
||||||
foreach (var entity in lookup.GetEntitiesIntersecting(gridId, offsets.Select(o => o + indices)))
|
|
||||||
{
|
{
|
||||||
if (_entMan.HasComponent<CargoTelepadComponent>(entity) && _entMan.TryGetComponent<ApcPowerReceiverComponent?>(entity, out var powerReceiver) && powerReceiver.Powered)
|
// use most recent link
|
||||||
{
|
var pad = telepad[^1].Uid;
|
||||||
cargoTelepad = entity;
|
if (_entMan.HasComponent<CargoTelepadComponent>(pad) &&
|
||||||
break;
|
_entMan.TryGetComponent<ApcPowerReceiverComponent?>(pad, out var powerReceiver) &&
|
||||||
}
|
powerReceiver.Powered)
|
||||||
|
cargoTelepad = pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cargoTelepad != null)
|
if (cargoTelepad != null)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Shared.Cargo;
|
using Content.Shared.Cargo;
|
||||||
using Content.Shared.Cargo.Components;
|
using Content.Shared.Cargo.Components;
|
||||||
|
using Content.Shared.MachineLinking;
|
||||||
using Content.Shared.Sound;
|
using Content.Shared.Sound;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
@@ -35,5 +36,8 @@ namespace Content.Server.Cargo.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("printerOutput", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
[DataField("printerOutput", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||||
public string PrinterOutput = "Paper";
|
public string PrinterOutput = "Paper";
|
||||||
|
|
||||||
|
[DataField("receiverPort", customTypeSerializer: typeof(PrototypeIdSerializer<ReceiverPortPrototype>))]
|
||||||
|
public string ReceiverPort = "OrderReceiver";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,4 +20,10 @@ signal-port-name-close = Close
|
|||||||
signal-port-description-close = Closes a device.
|
signal-port-description-close = Closes a device.
|
||||||
|
|
||||||
signal-port-name-trigger = Trigger
|
signal-port-name-trigger = Trigger
|
||||||
signal-port-description-trigger = Triggers some mechanism on the device.
|
signal-port-description-trigger = Triggers some mechanism on the device.
|
||||||
|
|
||||||
|
signal-port-name-order-sender = Order sender
|
||||||
|
signal-port-description-order-sender = Cargo console order sender
|
||||||
|
|
||||||
|
signal-port-name-order-receiver = Order receiver
|
||||||
|
signal-port-description-order-receiver = Cargo console order receiver
|
||||||
|
|||||||
@@ -32,8 +32,13 @@
|
|||||||
id: Close
|
id: Close
|
||||||
name: signal-port-name-close
|
name: signal-port-name-close
|
||||||
description: signal-port-description-close
|
description: signal-port-description-close
|
||||||
|
|
||||||
- type: receiverPort
|
- type: receiverPort
|
||||||
id: Trigger
|
id: Trigger
|
||||||
name: signal-port-name-trigger
|
name: signal-port-name-trigger
|
||||||
description: signal-port-description-trigger
|
description: signal-port-description-trigger
|
||||||
|
|
||||||
|
- type: receiverPort
|
||||||
|
id: OrderReceiver
|
||||||
|
name: signal-port-name-order-receiver
|
||||||
|
description: signal-port-description-order-receiver
|
||||||
|
|||||||
@@ -14,22 +14,28 @@
|
|||||||
id: Off
|
id: Off
|
||||||
name: signal-port-name-off-transmitter
|
name: signal-port-name-off-transmitter
|
||||||
description: signal-port-description-off-transmitter
|
description: signal-port-description-off-transmitter
|
||||||
defaultLinks: [ Off, Close]
|
defaultLinks: [ Off, Close ]
|
||||||
|
|
||||||
- type: transmitterPort
|
- type: transmitterPort
|
||||||
id: Left
|
id: Left
|
||||||
name: signal-port-name-left
|
name: signal-port-name-left
|
||||||
description: signal-port-description-left
|
description: signal-port-description-left
|
||||||
defaultLinks: [ On, Open, Forward, Trigger]
|
defaultLinks: [ On, Open, Forward, Trigger ]
|
||||||
|
|
||||||
- type: transmitterPort
|
- type: transmitterPort
|
||||||
id: Right
|
id: Right
|
||||||
name: signal-port-name-right
|
name: signal-port-name-right
|
||||||
description: signal-port-description-right
|
description: signal-port-description-right
|
||||||
defaultLinks: [ On, Open, Reverse, Trigger]
|
defaultLinks: [ On, Open, Reverse, Trigger ]
|
||||||
|
|
||||||
- type: transmitterPort
|
- type: transmitterPort
|
||||||
id: Middle
|
id: Middle
|
||||||
name: signal-port-name-middle
|
name: signal-port-name-middle
|
||||||
description: signal-port-description-middle
|
description: signal-port-description-middle
|
||||||
defaultLinks: [ Off, Close]
|
defaultLinks: [ Off, Close ]
|
||||||
|
|
||||||
|
- type: transmitterPort
|
||||||
|
id: OrderSender
|
||||||
|
name: signal-port-name-order-sender
|
||||||
|
description: signal-port-description-order-sender
|
||||||
|
defaultLinks: [ OrderReceiver ]
|
||||||
|
|||||||
Reference in New Issue
Block a user