* Predict dumping - This got soaped really fucking hard. - Dumping is predicted, this required disposals to be predicte.d - Disposals required mailing (because it's tightly coupled), and a smidge of other content systems. - I also had to fix a compnetworkgenerator issue at the same time so it wouldn't mispredict. * Fix a bunch of stuff * nasty merge * Some reviews * Some more reviews while I stash * Fix merge * Fix merge * Half of review * Review * re(h)f * lizards * feexes * feex
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using Content.Server.DeviceNetwork.Components;
|
|
using Content.Shared.DeviceNetwork.Events;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Content.Server.DeviceNetwork.Systems
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed class WirelessNetworkSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<WirelessNetworkComponent, BeforePacketSentEvent>(OnBeforePacketSent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the position of both the sending and receiving entity and checks if the receiver is in range of the sender.
|
|
/// </summary>
|
|
private void OnBeforePacketSent(EntityUid uid, WirelessNetworkComponent component, BeforePacketSentEvent args)
|
|
{
|
|
var ownPosition = args.SenderPosition;
|
|
var xform = Transform(uid);
|
|
|
|
// not a wireless to wireless connection, just let it happen
|
|
if (!TryComp<WirelessNetworkComponent>(args.Sender, out var sendingComponent))
|
|
return;
|
|
|
|
if (xform.MapID != args.SenderTransform.MapID
|
|
|| (ownPosition - _transformSystem.GetWorldPosition(xform)).Length() > sendingComponent.Range)
|
|
{
|
|
args.Cancel();
|
|
}
|
|
}
|
|
}
|
|
}
|