private void OnPacketRecv(EntityUid uid, AtmosAlarmableComponent component, DeviceNetworkPacketEvent args) { if (component.IgnoreAlarms) { return; } if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? netConn)) { return; } if (args.Data.TryGetValue(DeviceNetworkConstants.Command, out string?cmd) && cmd == AtmosMonitorSystem.AtmosMonitorAlarmCmd) { // does it have a state & network max state? // does it have a source? // and can this be alarmed by the source? // if so, raise an alarm if (args.Data.TryGetValue(DeviceNetworkConstants.CmdSetState, out AtmosMonitorAlarmType state) && args.Data.TryGetValue(AtmosMonitorSystem.AtmosMonitorAlarmNetMax, out AtmosMonitorAlarmType netMax) && args.Data.TryGetValue(AtmosMonitorSystem.AtmosMonitorAlarmSrc, out string?source) && component.AlarmedByPrototypes.Contains(source)) { component.LastAlarmState = state; component.HighestNetworkState = netMax; RaiseLocalEvent(component.Owner, new AtmosMonitorAlarmEvent(state, netMax), true); } } }
private void OnPacketRecv(EntityUid uid, AirAlarmComponent controller, DeviceNetworkPacketEvent args) { if (!args.Data.TryGetValue(DeviceNetworkConstants.Command, out string?cmd)) { return; } switch (cmd) { case AirAlarmSyncData: if (!args.Data.TryGetValue(AirAlarmSyncData, out IAtmosDeviceData? data) || data == null || !controller.CanSync) { break; } // Save into component. // Sync data to interface. // _airAlarmDataSystem.UpdateDeviceData(uid, args.SenderAddress, data); // _uiSystem.TrySendUiMessage(uid, SharedAirAlarmInterfaceKey.Key, new AirAlarmUpdateDeviceDataMessage(args.SenderAddress, data)); // if (HasComp<WiresComponent>(uid)) controller.UpdateWires(); if (!controller.DeviceData.TryAdd(args.SenderAddress, data)) { controller.DeviceData[args.SenderAddress] = data; } return; case AirAlarmSetDataStatus: if (!args.Data.TryGetValue(AirAlarmSetDataStatus, out bool dataStatus)) { break; } // Sync data to interface. // This should say if the result // failed, or succeeded. Don't save it.l SyncDevice(uid, args.SenderAddress); return; case AirAlarmSetMode: if (!args.Data.TryGetValue(AirAlarmSetMode, out AirAlarmMode alarmMode)) { break; } SetMode(uid, args.SenderAddress, alarmMode); return; } }
private void OnPacketRecv(EntityUid uid, GasVentPumpComponent component, DeviceNetworkPacketEvent args) { if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? netConn) || !EntityManager.TryGetComponent(uid, out AtmosAlarmableComponent? alarmable) || !args.Data.TryGetValue(DeviceNetworkConstants.Command, out var cmd)) { return; } var payload = new NetworkPayload(); switch (cmd) { case AirAlarmSystem.AirAlarmSyncCmd: payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSyncData); payload.Add(AirAlarmSystem.AirAlarmSyncData, component.ToAirAlarmData()); _deviceNetSystem.QueuePacket(uid, args.SenderAddress, payload, device: netConn); return; case AirAlarmSystem.AirAlarmSetData: if (!args.Data.TryGetValue(AirAlarmSystem.AirAlarmSetData, out GasVentPumpData? setData)) { break; } component.FromAirAlarmData(setData); UpdateState(uid, component); alarmable.IgnoreAlarms = setData.IgnoreAlarms; payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSetDataStatus); payload.Add(AirAlarmSystem.AirAlarmSetDataStatus, true); _deviceNetSystem.QueuePacket(uid, null, payload, device: netConn); return; } }
private void OnPacketReceived(EntityUid uid, DeviceNetworkComponent component, DeviceNetworkPacketEvent args) { LastPayload = args.Data; }
/// <summary> /// Turns the light on or of when receiving a <see cref="DeviceNetworkConstants.CmdSetState"/> command. /// The light is turned on or of according to the <see cref="DeviceNetworkConstants.StateEnabled"/> value /// </summary> private void OnPacketReceived(EntityUid uid, PoweredLightComponent component, DeviceNetworkPacketEvent args) { if (!args.Data.TryGetValue(DeviceNetworkConstants.Command, out string?command) || command != DeviceNetworkConstants.CmdSetState) { return; } if (!args.Data.TryGetValue(DeviceNetworkConstants.StateEnabled, out bool enabled)) { return; } SetState(uid, enabled, component); }
private void OnPacketReceive(EntityUid uid, SurveillanceCameraRouterComponent router, DeviceNetworkPacketEvent args) { if (!router.Active || string.IsNullOrEmpty(args.SenderAddress) || !args.Data.TryGetValue(DeviceNetworkConstants.Command, out string?command)) { return; } switch (command) { case SurveillanceCameraSystem.CameraConnectMessage: if (!args.Data.TryGetValue(SurveillanceCameraSystem.CameraAddressData, out string?address)) { return; } ConnectCamera(uid, args.SenderAddress, address, router); break; case SurveillanceCameraSystem.CameraHeartbeatMessage: if (!args.Data.TryGetValue(SurveillanceCameraSystem.CameraAddressData, out string?camera)) { return; } SendHeartbeat(uid, args.SenderAddress, camera, router); break; case SurveillanceCameraSystem.CameraSubnetConnectMessage: AddMonitorToRoute(uid, args.SenderAddress, router); PingSubnet(uid, router); break; case SurveillanceCameraSystem.CameraSubnetDisconnectMessage: RemoveMonitorFromRoute(uid, args.SenderAddress, router); break; case SurveillanceCameraSystem.CameraPingSubnetMessage: PingSubnet(uid, router); break; case SurveillanceCameraSystem.CameraPingMessage: SubnetPingResponse(uid, args.SenderAddress, router); break; case SurveillanceCameraSystem.CameraDataMessage: SendCameraInfo(uid, args.Data, router); break; } }
/// <summary> /// Listens to the <see cref="DeviceNetworkConstants.CmdSetState"/> command of other switches to sync state /// </summary> private void OnPackedReceived(EntityUid uid, ApcNetSwitchComponent component, DeviceNetworkPacketEvent args) { if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? networkComponent) || args.SenderAddress == networkComponent.Address) { return; } if (!args.Data.TryGetValue(DeviceNetworkConstants.Command, out string?command) || command != DeviceNetworkConstants.CmdSetState) { return; } if (!args.Data.TryGetValue(DeviceNetworkConstants.StateEnabled, out bool enabled)) { return; } component.State = enabled; }
private void OnPacketReceived(EntityUid uid, CrewMonitoringConsoleComponent component, DeviceNetworkPacketEvent args) { var suitSensor = _sensors.PacketToSuitSensor(args.Data); if (suitSensor == null) { return; } suitSensor.Timestamp = _gameTiming.CurTime; component.ConnectedSensors[args.SenderAddress] = suitSensor; }
private void OnPacketReceived(EntityUid uid, SurveillanceCameraComponent component, DeviceNetworkPacketEvent args) { if (!component.Active) { return; } if (!TryComp(uid, out DeviceNetworkComponent? deviceNet)) { return; } if (args.Data.TryGetValue(DeviceNetworkConstants.Command, out string?command)) { var payload = new NetworkPayload() { { DeviceNetworkConstants.Command, string.Empty }, { CameraAddressData, deviceNet.Address }, { CameraNameData, component.CameraId }, { CameraSubnetData, string.Empty } }; var dest = string.Empty; switch (command) { case CameraConnectMessage: if (!args.Data.TryGetValue(CameraAddressData, out dest) || string.IsNullOrEmpty(args.Address)) { return; } payload[DeviceNetworkConstants.Command] = CameraConnectMessage; break; case CameraHeartbeatMessage: if (!args.Data.TryGetValue(CameraAddressData, out dest) || string.IsNullOrEmpty(args.Address)) { return; } payload[DeviceNetworkConstants.Command] = CameraHeartbeatMessage; break; case CameraPingMessage: if (!args.Data.TryGetValue(CameraSubnetData, out string?subnet)) { return; } dest = args.SenderAddress; payload[CameraSubnetData] = subnet; payload[DeviceNetworkConstants.Command] = CameraDataMessage; break; } _deviceNetworkSystem.QueuePacket( uid, dest, payload); } }
private void OnPacketReceived(EntityUid uid, SurveillanceCameraMonitorComponent component, DeviceNetworkPacketEvent args) { if (string.IsNullOrEmpty(args.SenderAddress)) { return; } if (args.Data.TryGetValue(DeviceNetworkConstants.Command, out string?command)) { switch (command) { case SurveillanceCameraSystem.CameraConnectMessage: if (component.NextCameraAddress == args.SenderAddress) { component.ActiveCameraAddress = args.SenderAddress; TrySwitchCameraByUid(uid, args.Sender, component); } component.NextCameraAddress = null; break; case SurveillanceCameraSystem.CameraHeartbeatMessage: if (args.SenderAddress == component.ActiveCameraAddress) { component.LastHeartbeat = 0; } break; case SurveillanceCameraSystem.CameraDataMessage: if (!args.Data.TryGetValue(SurveillanceCameraSystem.CameraNameData, out string?name) || !args.Data.TryGetValue(SurveillanceCameraSystem.CameraSubnetData, out string?subnetData) || !args.Data.TryGetValue(SurveillanceCameraSystem.CameraAddressData, out string?address)) { return; } if (component.ActiveSubnet != subnetData) { DisconnectFromSubnet(uid, subnetData); } if (!component.KnownCameras.ContainsKey(address)) { component.KnownCameras.Add(address, name); } UpdateUserInterface(uid, component); break; case SurveillanceCameraSystem.CameraSubnetData: if (args.Data.TryGetValue(SurveillanceCameraSystem.CameraSubnetData, out string?subnet) && !component.KnownSubnets.ContainsKey(subnet)) { component.KnownSubnets.Add(subnet, args.SenderAddress); } UpdateUserInterface(uid, component); break; } } }