Rejig Device networks (#7380)

This commit is contained in:
Leon Friedrich
2022-04-09 00:27:10 +12:00
committed by GitHub
parent 44649e7fed
commit a4d55235cc
33 changed files with 671 additions and 247 deletions

View File

@@ -42,9 +42,6 @@ namespace Content.Server.Atmos.Monitor.Systems
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
#region Device Network API
public const int Freq = AtmosMonitorSystem.AtmosMonitorApcFreq;
/// <summary>
/// Command to set device data within the air alarm's network.
/// </summary>
@@ -93,7 +90,7 @@ namespace Content.Server.Atmos.Monitor.Systems
[AirAlarmSetData] = data
};
_deviceNet.QueuePacket(uid, address, Freq, payload);
_deviceNet.QueuePacket(uid, address, payload);
}
/// <summary>
@@ -110,7 +107,7 @@ namespace Content.Server.Atmos.Monitor.Systems
[DeviceNetworkConstants.Command] = AirAlarmSyncCmd
};
_deviceNet.QueuePacket(uid, string.Empty, Freq, payload, true);
_deviceNet.QueuePacket(uid, null, payload);
}
/// <summary>
@@ -129,7 +126,7 @@ namespace Content.Server.Atmos.Monitor.Systems
[DeviceNetworkConstants.Command] = AirAlarmSyncCmd
};
_deviceNet.QueuePacket(uid, address, Freq, payload);
_deviceNet.QueuePacket(uid, address, payload);
}
/// <summary>
@@ -148,7 +145,7 @@ namespace Content.Server.Atmos.Monitor.Systems
[AirAlarmSetMode] = mode
};
_deviceNet.QueuePacket(uid, string.Empty, Freq, payload, true);
_deviceNet.QueuePacket(uid, null, payload);
}
#endregion
@@ -157,7 +154,7 @@ namespace Content.Server.Atmos.Monitor.Systems
public override void Initialize()
{
SubscribeLocalEvent<AirAlarmComponent, PacketSentEvent>(OnPacketRecv);
SubscribeLocalEvent<AirAlarmComponent, DeviceNetworkPacketEvent>(OnPacketRecv);
SubscribeLocalEvent<AirAlarmComponent, AtmosDeviceUpdateEvent>(OnAtmosUpdate);
SubscribeLocalEvent<AirAlarmComponent, AtmosMonitorAlarmEvent>(OnAtmosAlarm);
SubscribeLocalEvent<AirAlarmComponent, PowerChangedEvent>(OnPowerChanged);
@@ -383,7 +380,7 @@ namespace Content.Server.Atmos.Monitor.Systems
SetData(uid, address, devData);
}
private void OnPacketRecv(EntityUid uid, AirAlarmComponent controller, PacketSentEvent args)
private void OnPacketRecv(EntityUid uid, AirAlarmComponent controller, DeviceNetworkPacketEvent args)
{
if (!args.Data.TryGetValue(DeviceNetworkConstants.Command, out string? cmd))
return;