using Content.Server.DeviceNetwork.Components; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.DeviceNetwork.Systems { [UsedImplicitly] public class WirelessNetworkSystem : EntitySystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnBeforePacketSent); } /// /// Gets the position of both the sending and receiving entity and checks if the receiver is in range of the sender. /// private void OnBeforePacketSent(EntityUid uid, WirelessNetworkComponent component, BeforePacketSentEvent args) { var sender = args.Sender var ownPosition = IoCManager.Resolve().GetComponent(component.Owner).WorldPosition; var position = IoCManager.Resolve().GetComponent(sender).WorldPosition; var distance = (ownPosition - position).Length; if(IoCManager.Resolve().TryGetComponent(sender, out var sendingComponent) && distance > sendingComponent.Range) { args.Cancel(); } } } }