Files
tbd-station-14/Content.Server/DeviceNetwork/Systems/WiredNetworkSystem.cs
2022-06-12 11:54:41 +10:00

32 lines
1.1 KiB
C#

using Content.Server.DeviceNetwork.Components;
using JetBrains.Annotations;
namespace Content.Server.DeviceNetwork.Systems
{
[UsedImplicitly]
public sealed class WiredNetworkSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<WiredNetworkComponent, BeforePacketSentEvent>(OnBeforePacketSent);
}
/// <summary>
/// Checks if both devices are on the same grid
/// </summary>
private void OnBeforePacketSent(EntityUid uid, WiredNetworkComponent component, BeforePacketSentEvent args)
{
if (EntityManager.GetComponent<TransformComponent>(uid).GridEntityId != args.SenderTransform.GridEntityId)
{
args.Cancel();
}
}
//Things to do in a future PR:
//Abstract out the connection between the apcExtensionCable and the apcPowerReceiver
//Traverse the power cables using path traversal
//Cache an optimized representation of the traversed path (Probably just cache Devices)
}
}