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;

View File

@@ -11,10 +11,10 @@ namespace Content.Server.Atmos.Monitor.Systems
{
public override void Initialize()
{
SubscribeLocalEvent<AtmosAlarmableComponent, PacketSentEvent>(OnPacketRecv);
SubscribeLocalEvent<AtmosAlarmableComponent, DeviceNetworkPacketEvent>(OnPacketRecv);
}
private void OnPacketRecv(EntityUid uid, AtmosAlarmableComponent component, PacketSentEvent args)
private void OnPacketRecv(EntityUid uid, AtmosAlarmableComponent component, DeviceNetworkPacketEvent args)
{
if (component.IgnoreAlarms) return;

View File

@@ -62,11 +62,6 @@ namespace Content.Server.Atmos.Monitor.Systems
/// </summary>
public const string AtmosMonitorAlarmNetMax = "atmos_monitor_alarm_net_max";
/// <summary>
/// Frequency (all prototypes that use AtmosMonitor should use this)
/// </summary>
public const int AtmosMonitorApcFreq = 1621;
public override void Initialize()
{
SubscribeLocalEvent<AtmosMonitorComponent, ComponentInit>(OnAtmosMonitorInit);
@@ -76,7 +71,7 @@ namespace Content.Server.Atmos.Monitor.Systems
SubscribeLocalEvent<AtmosMonitorComponent, TileFireEvent>(OnFireEvent);
SubscribeLocalEvent<AtmosMonitorComponent, PowerChangedEvent>(OnPowerChangedEvent);
SubscribeLocalEvent<AtmosMonitorComponent, BeforePacketSentEvent>(BeforePacketRecv);
SubscribeLocalEvent<AtmosMonitorComponent, PacketSentEvent>(OnPacketRecv);
SubscribeLocalEvent<AtmosMonitorComponent, DeviceNetworkPacketEvent>(OnPacketRecv);
}
private void OnAtmosMonitorInit(EntityUid uid, AtmosMonitorComponent component, ComponentInit args)
@@ -158,7 +153,7 @@ namespace Content.Server.Atmos.Monitor.Systems
if (!component.NetEnabled) args.Cancel();
}
private void OnPacketRecv(EntityUid uid, AtmosMonitorComponent component, PacketSentEvent args)
private void OnPacketRecv(EntityUid uid, AtmosMonitorComponent component, DeviceNetworkPacketEvent args)
{
// sync the internal 'last alarm state' from
// the other alarms, so that we can calculate
@@ -389,7 +384,7 @@ namespace Content.Server.Atmos.Monitor.Systems
[AtmosMonitorAlarmSrc] = prototype != null ? prototype.ID : string.Empty
};
_deviceNetSystem.QueuePacket(monitor.Owner, string.Empty, AtmosMonitorApcFreq, payload, true);
_deviceNetSystem.QueuePacket(monitor.Owner, null, payload);
monitor.NetworkAlarmStates.Clear();
Alert(uid, AtmosMonitorAlarmType.Normal, null, monitor);
@@ -411,7 +406,7 @@ namespace Content.Server.Atmos.Monitor.Systems
[AtmosMonitorAlarmSrc] = prototype != null ? prototype.ID : string.Empty
};
_deviceNetSystem.QueuePacket(monitor.Owner, string.Empty, AtmosMonitorApcFreq, payload, true);
_deviceNetSystem.QueuePacket(monitor.Owner, null, payload);
}
/// <summary>
@@ -445,7 +440,7 @@ namespace Content.Server.Atmos.Monitor.Systems
[AtmosMonitorAlarmSrc] = source
};
_deviceNetSystem.QueuePacket(monitor.Owner, string.Empty, AtmosMonitorApcFreq, payload, true);
_deviceNetSystem.QueuePacket(monitor.Owner, null, payload);
}
/// <summary>

View File

@@ -35,7 +35,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
SubscribeLocalEvent<GasVentPumpComponent, AtmosDeviceDisabledEvent>(OnGasVentPumpLeaveAtmosphere);
SubscribeLocalEvent<GasVentPumpComponent, AtmosMonitorAlarmEvent>(OnAtmosAlarm);
SubscribeLocalEvent<GasVentPumpComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<GasVentPumpComponent, PacketSentEvent>(OnPacketRecv);
SubscribeLocalEvent<GasVentPumpComponent, DeviceNetworkPacketEvent>(OnPacketRecv);
}
private void OnGasVentPumpUpdated(EntityUid uid, GasVentPumpComponent vent, AtmosDeviceUpdateEvent args)
@@ -162,7 +162,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
component.Enabled = args.Powered;
}
private void OnPacketRecv(EntityUid uid, GasVentPumpComponent component, PacketSentEvent args)
private void OnPacketRecv(EntityUid uid, GasVentPumpComponent component, DeviceNetworkPacketEvent args)
{
if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent netConn)
|| !EntityManager.TryGetComponent(uid, out AtmosAlarmableComponent alarmable)
@@ -177,7 +177,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSyncData);
payload.Add(AirAlarmSystem.AirAlarmSyncData, component.ToAirAlarmData());
_deviceNetSystem.QueuePacket(uid, args.SenderAddress, AirAlarmSystem.Freq, payload);
_deviceNetSystem.QueuePacket(uid, args.SenderAddress, payload, device: netConn);
return;
case AirAlarmSystem.AirAlarmSetData:
@@ -189,7 +189,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSetDataStatus);
payload.Add(AirAlarmSystem.AirAlarmSetDataStatus, true);
_deviceNetSystem.QueuePacket(uid, string.Empty, AirAlarmSystem.Freq, payload, true);
_deviceNetSystem.QueuePacket(uid, null, payload, device: netConn);
return;
}

View File

@@ -36,7 +36,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
SubscribeLocalEvent<GasVentScrubberComponent, AtmosDeviceDisabledEvent>(OnVentScrubberLeaveAtmosphere);
SubscribeLocalEvent<GasVentScrubberComponent, AtmosMonitorAlarmEvent>(OnAtmosAlarm);
SubscribeLocalEvent<GasVentScrubberComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<GasVentScrubberComponent, PacketSentEvent>(OnPacketRecv);
SubscribeLocalEvent<GasVentScrubberComponent, DeviceNetworkPacketEvent>(OnPacketRecv);
}
private void OnVentScrubberUpdated(EntityUid uid, GasVentScrubberComponent scrubber, AtmosDeviceUpdateEvent args)
@@ -136,7 +136,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnPowerChanged(EntityUid uid, GasVentScrubberComponent component, PowerChangedEvent args) =>
component.Enabled = args.Powered;
private void OnPacketRecv(EntityUid uid, GasVentScrubberComponent component, PacketSentEvent args)
private void OnPacketRecv(EntityUid uid, GasVentScrubberComponent component, DeviceNetworkPacketEvent args)
{
if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent netConn)
|| !EntityManager.TryGetComponent(uid, out AtmosAlarmableComponent alarmable)
@@ -151,7 +151,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSyncData);
payload.Add(AirAlarmSystem.AirAlarmSyncData, component.ToAirAlarmData());
_deviceNetSystem.QueuePacket(uid, args.SenderAddress, AirAlarmSystem.Freq, payload);
_deviceNetSystem.QueuePacket(uid, args.SenderAddress, payload, device: netConn);
return;
case AirAlarmSystem.AirAlarmSetData:
@@ -163,7 +163,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSetDataStatus);
payload.Add(AirAlarmSystem.AirAlarmSetDataStatus, true);
_deviceNetSystem.QueuePacket(uid, string.Empty, AirAlarmSystem.Freq, payload, true);
_deviceNetSystem.QueuePacket(uid, null, payload, device: netConn);
return;
}