Device Linking and better linking ui (#13645)
Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com> Co-authored-by: Visne <39844191+Visne@users.noreply.github.com> Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
37
Content.Server/DeviceLinking/Systems/AutoLinkSystem.cs
Normal file
37
Content.Server/DeviceLinking/Systems/AutoLinkSystem.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.MachineLinking.System;
|
||||
|
||||
namespace Content.Server.DeviceLinking.Systems;
|
||||
|
||||
/// <summary>
|
||||
/// This handles automatically linking autolinked entities at round-start.
|
||||
/// </summary>
|
||||
public sealed class AutoLinkSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly DeviceLinkSystem _deviceLinkSystem = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<AutoLinkTransmitterComponent, MapInitEvent>(OnAutoLinkMapInit);
|
||||
}
|
||||
|
||||
private void OnAutoLinkMapInit(EntityUid uid, AutoLinkTransmitterComponent component, MapInitEvent args)
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
|
||||
foreach (var receiver in EntityQuery<AutoLinkReceiverComponent>())
|
||||
{
|
||||
if (receiver.AutoLinkChannel != component.AutoLinkChannel)
|
||||
continue; // Not ours.
|
||||
|
||||
var rxXform = Transform(receiver.Owner);
|
||||
|
||||
if (rxXform.GridUid != xform.GridUid)
|
||||
continue;
|
||||
|
||||
_deviceLinkSystem.LinkDefaults(null, uid, receiver.Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user