#nullable enable using Content.Shared.DeviceNetwork; using Content.Shared.DeviceNetwork.Events; using Robust.Shared.GameObjects; using Robust.Shared.Reflection; using Content.Shared.DeviceNetwork.Components; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.IntegrationTests.Tests.DeviceNetwork; [Reflect(false)] public sealed partial class DeviceNetworkTestSystem : EntitySystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnBaselinePacketReceived); SubscribeLocalEvent>(OnTypedPacketReceived); SubscribeLocalEvent>(OnTypedPacketReceived); } public TestPayload LastPayload = default; public SecondTestPayload LastPayloadSecond = default; public TestPayloadClass LastPayloadClass = default!; public void SendBaselineTestEvent(EntityUid uid) { var ev = new DeviceNetworkPacketData(0, "", 0, "", uid, new TestPayloadClass()); RaiseLocalEvent(uid, ref ev); } private void OnBaselinePacketReceived(Entity ent, ref DeviceNetworkPacketData args) { LastPayloadClass = (TestPayloadClass) args.Data; } private void OnTypedPacketReceived(Entity ent, ref DeviceNetworkPacketEvent args) { LastPayload = args.Data; } private void OnTypedPacketReceived(Entity ent, ref DeviceNetworkPacketEvent args) { LastPayloadSecond = args.Data; } } [ByRefEvent] public record struct DeviceNetworkPacketData( int NetId, string? Address, uint Frequency, string SenderAddress, EntityUid Sender, INetworkPayload Data); public readonly partial record struct TestPayload(string TestString, int TestNumber, bool TestBool) : INetworkPayload; public readonly partial record struct SecondTestPayload(string TestString, int TestNumber, bool TestBool) : INetworkPayload; public sealed partial class TestPayloadClass : INetworkPayload { [DataField] public string TestString; [DataField] public int TestNumber; [DataField] public bool TestBool; }