Rejig Device networks (#7380)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user