Cargo telepad machine linking (#7756)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,27 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Coordinates.Helpers;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Shared.Cargo.Components;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Shared.MachineLinking;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Cargo.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class CargoConsoleComponent : SharedCargoConsoleComponent
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
private CargoBankAccount? _bankAccount;
|
||||
@@ -64,6 +58,9 @@ namespace Content.Server.Cargo.Components
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(CargoConsoleUiKey.Key);
|
||||
|
||||
[DataField("senderPort", customTypeSerializer: typeof(PrototypeIdSerializer<TransmitterPortPrototype>))]
|
||||
public string SenderPort = "OrderSender";
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -160,23 +157,18 @@ namespace Content.Server.Cargo.Components
|
||||
//orders.Database.ClearOrderCapacity();
|
||||
|
||||
// TODO replace with shuttle code
|
||||
// TEMPORARY loop for spawning stuff on telepad (looks for a telepad adjacent to the console)
|
||||
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>();
|
||||
var gridId = _entMan.GetComponent<TransformComponent>(Owner).GridID;
|
||||
|
||||
// TODO: Should use anchoring.
|
||||
foreach (var entity in lookup.GetEntitiesIntersecting(gridId, offsets.Select(o => o + indices)))
|
||||
if (_entMan.TryGetComponent<SignalTransmitterComponent>(Owner, out var transmitter) &&
|
||||
transmitter.Outputs.TryGetValue(SenderPort, out var telepad) &&
|
||||
telepad.Count > 0)
|
||||
{
|
||||
if (_entMan.HasComponent<CargoTelepadComponent>(entity) && _entMan.TryGetComponent<ApcPowerReceiverComponent?>(entity, out var powerReceiver) && powerReceiver.Powered)
|
||||
{
|
||||
cargoTelepad = entity;
|
||||
break;
|
||||
}
|
||||
// use most recent link
|
||||
var pad = telepad[^1].Uid;
|
||||
if (_entMan.HasComponent<CargoTelepadComponent>(pad) &&
|
||||
_entMan.TryGetComponent<ApcPowerReceiverComponent?>(pad, out var powerReceiver) &&
|
||||
powerReceiver.Powered)
|
||||
cargoTelepad = pad;
|
||||
}
|
||||
|
||||
if (cargoTelepad != null)
|
||||
|
||||
Reference in New Issue
Block a user