* Work on DeviceNetworkSystem * Implement device networking as ecs Remove mailing unit code for now Remove device network metadata * Implement integration tests for device networking * Remove manual updating DeviceNetworkSystem and use WaitRunTicks * Fix wrong component name in ignored components * Apply suggestions from code review Co-authored-by: mirrorcult <notzombiedude@gmail.com> * Rename NetworkUtils to DeviceNetworkConstants Change connection type constants to enum Remove create function from network payload class * Change broken nodegroup check in wirenet to grid check * Change ComponentManager to entity manager in DeviceNetworkSystem * Fix smaller mistakes * Wtf random test fail pls run them again smh * Fix DataField in DeviceNetworkComponent * Fix yaml in DeviceNetworkTest * Fix DeviceNetworkComponent DeviceNetId property Co-authored-by: Julian Giebel <j.giebel@netrocks.info> Co-authored-by: mirrorcult <notzombiedude@gmail.com>
40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using Content.Server.DeviceNetwork.Components;
|
|
using Content.Server.NodeContainer;
|
|
using Content.Server.NodeContainer.NodeGroups;
|
|
using Content.Server.Power.Components;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.GameObjects;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace Content.Server.DeviceNetwork.Systems
|
|
{
|
|
[UsedImplicitly]
|
|
public 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)
|
|
{
|
|
IEntity sender = EntityManager.GetEntity(args.Sender);
|
|
IEntity receiver = EntityManager.GetEntity(uid);
|
|
|
|
if (receiver.Transform.GridID != sender.Transform.GridID)
|
|
{
|
|
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)
|
|
}
|
|
}
|