mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-09-15 14:52:26 +02:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using Content.Server.DeviceLinking.Components;
|
|
|
|
namespace Content.Server.DeviceLinking.Systems;
|
|
|
|
/// <summary>
|
|
/// This handles automatically linking autolinked entities at round-start.
|
|
/// </summary>
|
|
public sealed partial class AutoLinkSystem : EntitySystem
|
|
{
|
|
[Dependency] private 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);
|
|
|
|
var query = EntityQueryEnumerator<AutoLinkReceiverComponent>();
|
|
while (query.MoveNext(out var receiverUid, out var receiver))
|
|
{
|
|
if (receiver.AutoLinkChannel != component.AutoLinkChannel)
|
|
continue; // Not ours.
|
|
|
|
var rxXform = Transform(receiverUid);
|
|
|
|
if (rxXform.GridUid != xform.GridUid)
|
|
continue;
|
|
|
|
_deviceLinkSystem.LinkDefaults(null, uid, receiverUid);
|
|
}
|
|
}
|
|
}
|
|
|