WiredNetworkSystem.cs 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. using Content.Server.DeviceNetwork.Components;
  2. using JetBrains.Annotations;
  3. namespace Content.Server.DeviceNetwork.Systems
  4. {
  5. [UsedImplicitly]
  6. public sealed class WiredNetworkSystem : EntitySystem
  7. {
  8. public override void Initialize()
  9. {
  10. base.Initialize();
  11. SubscribeLocalEvent<WiredNetworkComponent, BeforePacketSentEvent>(OnBeforePacketSent);
  12. }
  13. /// <summary>
  14. /// Checks if both devices are on the same grid
  15. /// </summary>
  16. private void OnBeforePacketSent(EntityUid uid, WiredNetworkComponent component, BeforePacketSentEvent args)
  17. {
  18. if (Transform(uid).GridUid != args.SenderTransform.GridUid)
  19. {
  20. args.Cancel();
  21. }
  22. }
  23. //Things to do in a future PR:
  24. //Abstract out the connection between the apcExtensionCable and the apcPowerReceiver
  25. //Traverse the power cables using path traversal
  26. //Cache an optimized representation of the traversed path (Probably just cache Devices)
  27. }
  28. }