* C# half of Outer Rim commit 5081906bd17e715ecae422dd7a003d9f103e6884 "autolink gaming." Ported from Outer Rim with permission. * YAML half of Outer Rim commit 5081906bd17e715ecae422dd7a003d9f103e6884 "autolink gaming." Ported from Outer Rim with permission. * commit fixed AL summary Co-authored-by: Moony <moonheart08@users.noreply.github.com> * NewLinkEvent.User & LinkAttemptEvent.User now nullable, fix possible AccessReaderSystem AutoLink bug Co-authored-by: Moony <moonheart08@users.noreply.github.com>
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using Content.Server.MachineLinking.Components;
|
|
|
|
namespace Content.Server.MachineLinking.System;
|
|
|
|
/// <summary>
|
|
/// This handles automatically linking autolinked entities at round-start.
|
|
/// </summary>
|
|
public sealed class AutoLinkSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SignalLinkerSystem _signalLinkerSystem = 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;
|
|
|
|
_signalLinkerSystem.TryLinkDefaults(receiver.Owner, uid, null);
|
|
}
|
|
}
|
|
}
|
|
|